Okey, for use ini_set('memory_limit', '512M');
but is not good pratice in production.
Better approach is to optimize memory usage: avoid reloading and resaving the file on each batch.
Keep one $spreadsheet
instance, write rows progressively, then save once at the end.
Reloading the file introduces hidden links or references (Unable to access External Workbook
), which break the document.
Also, don't forget to unset()
and call $spreadsheet->disconnectWorksheets();
after saving, to release memory.
Have nice day,
Kind regards.