I'm setting up an export feature based on the generated report, and am having problems when inserting large array rows/data to a sheet using Laravel Excel 2.1
's fromArray
method. Is there any alternate way to do this to not get 'Allowed memmory size exhausted'?
I already tried array_chunk
method but I'm still getting the memory exhaustion error.
$reportData = $this->report->run(); // Depending on the filters of the report, it can get upto 20,000 rows.
$headers = Input::get('selectedcolumns');
$data = [];
foreach($report['data'] as $value) {
$row = [];
foreach($headers as $header) {
$row[$header['label']] = $value[$header['name']];
}
$data[] = $row;
}
return Excel::create('Excel', function($excel) use($data) {
$excel->sheet('Sheet1', function($sheet) use($data) {
->sheet->fromArray($data);
});
})->store('xls', false, true);