我想使用 maatweb 包将视图中的所有记录导出到 excel 表中
在我的控制器中,我使用了以下功能
public function exportAll()
{
Excel::create('POs', function ($excel)
{
$excel->setTitle('Pos');
$excel->sheet('POs', function ($sheet)
{
$pos = PO::all();
$arr =array();
foreach($pos as $po)
{
foreach ($po->mr as $m)
foreach ($po->suppliers as $supplier)
{
$data = array($m->mr_no, $po->po_no, $po->po_subject,
$po->po_issued, $po->po_total_cost, $po->po_currency,
$po->po_purchase_method, $po->po_payment_method,
$po->po_delivery_method, $po->po_confirmation,
$po->po_loaded_on_ideas, $supplier->vname,
$po->po_loaded_on_ideas, $po->po_approved_on_ideas,
$po->memo_to_fin, $po->po_delivery_date,
$po->po_mr_received_date, $po->po_mrr_received_date,
$po->po_invoice_received_date, $po->po_penalty,
$po->po_cover_invoice, $po->po_completed
);
array_push($arr, $data);
}
}
$sheet->loadView( 'pos.pos_all_template' )->with('pos',$pos);
//
});
})->export('xlsx');
}
在路由文件中我使用了
Route::get('po_s/exportall','POsController@exportAll');
在我的视图文件中
@foreach($pos as $p)
@foreach($p->mr as $m)
@foreach($p->suppliers as $s)
<tr style="color:rgb(0, 0, 0);" align="center" >
<th align="center" > {{ $m['mr_no'] }} </th>
<th align="center" > {{ $p['po_no'] }} </th>
<th align="center" > {{ $p['po_subject'] }} </th>
<th align="center" >{{ $p['po_issued'] }} </th>
<th align="center" >{{ $s['vname'] }} </th>
<th align="center" >{{ $p['po_total_cost'] }} </th>
<th align="center" >{{ $p['po_currency'] }} </th>
<th align="center" >{{ $p['po_purchase_method'] }} </th>
<th align="center" >{{ $p['po_payment_method'] }} </th>
<th align="center" >{{ $p['po_delivery_method'] }} </th>
<th align="center" >{{ $p['po_delivery_date'] }} </th>
<th align="center" >{{ $p['po_loaded_on_ideas'] }} </th>
<th align="center" >{{ $p['po_mr_received_date'] }} </th>
<th align="center" >{{ $p['po_mrr_received_date'] }} </th>
<th align="center" >{{ $p['po_invoice_received_date'] }} </th>
<th align="center" >{{ $p['po_penalty'] }} </th>
<th align="center" >{{ $p['po_cover_invoice'] }} </th>
<th align="center" >{{ $p['po_completed'] }} </th>
</tr>
@endforeach
@endforeach
@endforeach
问题我收到没有任何数据的空 excel 文件