php - exporting large files in separate sheets Laravel Maatwebsite -
i have 50,000 raw. want export them system fails export it. using code. there better solution this?
excel::create('catalogdumptreport', function ($excel) use ($finalarray) { $excel->sheet('catalogdumptreport', function ($sheet) use ($finalarray) { $sheet->fromarray($finalarray); $sheet->setfontfamily('verdana'); $sheet->setfontsize(10); $sheet->row(1, function ($row) { $row->setfontweight('bold'); }); $sheet->setborder('a1', 'thin'); $sheet->setheight(1, 20); }); })->export('xls') ->download('xls');
personally, advise against expoting such large xls files (directly in browser). best way (and fastest) export in background (such async laravel queue etc.).
there 2 computational complexity problem:
- time complexity - grows fast means time download in example severely hrows too.
- complexity of memory - can exhaust memory resources on machine can exhaust memory resources on machine fast - means not current system/program can act every other lunched on machine.
as said best way put xle generating in background - there's more:
you need find way split data , append portions of data - not @ once. can save memory resources.
after export in queue can check in browser through ajax request if file ready download , let user dowload prepared xls file.