我正在尝试从A1开始换行,但是它无法正常工作,并引发错误,找不到getStyle方法
Excel::create('complaint_report', function ($excel) use ($compsArray) {
// Set the spreadsheet title, creator, and description
$excel->setTitle('complaints report');
$excel->setCreator('Laravel')->setCompany('Beegains, LLC');
$excel->setDescription('complaints file');
// Build the spreadsheet, passing in the comps array
$excel->sheet('sheet1', function ($sheet) use ($compsArray) {
$sheet->fromArray($compsArray, null,getStyle('A1')->getAlignment()->setWrapText(true), false, false);
});
})->download('xlsx');
答案 0 :(得分:1)
您不能在工作表上调用getStyle
函数。只需更新至:
$sheet->fromArray($compsArray, null, 'A1', false, false)
->getStyle('A1')
->getAlignment()
->setWrapText(true);