2. 实现
$path = storage_path('exports/file.xls');
Excel::load($path, function ($reader) use ($data) {
$reader->sheet(0, function ($sheet) use ($data, $total_invoice_amount, $total_num, $total_untax_amount, $total_amount, $invoice_verify, $supplier_address) {
$sheet->cell('B2', $data['supplier_info']);
$sheet->cell('D2', $data['supplier_info']);
$invoice_start = 5;
foreach ($data['invoice'] as $item) {
$sheet->insertNewRowBefore($invoice_start,1);
$sheet->appendRow($invoice_start++, $item, true);
})->export('xlsx');
遇到的问题&解决方法
如果想要的excel操作上文没提及,可以找下这个文件:
excel源码:vendor-naatwebsite-excel-src-Maatwebsite-Excel-Classes-LaravelExcelWorksheet.php
export('xls'),导出格式为xls的时候脚本报错,改为export('xlsx')即可
文章被阅读
10,466
1. excel操作