Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

php - Set excel data foreach horizontally using fromView Laravel Maatwebsite

currently Im using laravel maatwebsite fromView to styling my Excel template where I can download it later, the issue is in here, after I set the table to loop the data horizontally which is I view and tested it using browser, but when I downloaded the excel it become vertical, how can I fix this issue?

Example in my browser

enter image description here

below is excel view

enter image description here

<style>
.table {
  float: left;
}
table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
th, td {
  padding: 5px;
  text-align: left;
}
</style>
@php
  $loop_index = 1;
@endphp
@for ($count=0; $count<=count($all_sales); $count+=8)
    <table border="1">
      <td>
      @foreach ($all_sales->slice($count, 8) as $bil => $days)
        @php
          $loop_indexing = $loop_index++
        @endphp
        <table class="table" border="1">
            <tr>
              <td colspan="5">{{ $bil }}</td>
            </tr>
            <tr>
              <td colspan="5">
                @php
                  $registered_nos = $days->values()->collapse()->map(function($day) {
                    /* check whether it is only whitespace */
                    if(!trim($day->registered_no) == '')
                    {
                      return $day->registered_no;
                    }
                  })->unique();
                  $registered_no = implode($registered_nos->reverse()->toArray(), ' / ');
                @endphp
                {{ $registered_no }}
              </td>
            </tr>
            </table>
      @endforeach
      </td>
  </table>
@endfor
question from:https://stackoverflow.com/questions/65913146/set-excel-data-foreach-horizontally-using-fromview-laravel-maatwebsite

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...