使用 fromView Laravel Maatwebsite 水平设置 excel 数据 foreach

问题描述

目前我使用 laravel maatwebsite fromView 为我的 Excel 模板设计样式,我可以稍后下载它,问题就在这里,在我将表格设置为水平循环数据后,我使用浏览器查看并测试了它,但是当我下载的 excel 变成垂直了,我该如何解决这个问题?

浏览器中的示例

enter image description here

下面是excel视图

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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)