Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

burntstove's avatar

Exporting Large amount of data

hello, i'm having problem exporting large amount of data to Excel. I currently using Laravel Excel (maatwebsite/excel) to do this but i keep having too large memory problem. Is there away to solve solve this? or is there a way better way to export large amount data to excel?

thanks.

0 likes
1 reply
Tray2's avatar

I would create a job that exports the data into csv, and then converts that csv into excel.

SELECT ... FROM ... WHERE ... 
INTO OUTFILE 'file.csv'
FIELDS TERMINATED BY ','

And then use PHPSpreadsheet to convert it to excel.

https://github.com/PHPOffice/PhpSpreadsheet

Then when it's finished notify the user, that they can download the exported file.

Please or to participate in this conversation.