0

I am getting the below error when exporting large data into excel.

Setting the memory_limit variable in the script solves the problem, but that is not the proper solution.

Has anybody faced this kind of problem and solved it? Please help me to solve this too.

Error message:

E_ERROR: Allowed memory size of 268435456 bytes exhausted (tried to allocate 32 bytes)

Stack trace:

…c/vendor/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/CacheBase.php (173) …c/vendor/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/CacheBase.php (205) …c/vendor/phpoffice/phpexcel/Classes/PHPExcel/CachedObjectStorage/CacheBase.php (264) …/goget.com.au/www/src/vendor/phpoffice/phpexcel/Classes/PHPExcel/Worksheet.php (1045) …goget.com.au/www/src/vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/CSV.php (128) ….au/www/src/vendor/fleetcutter/components/src/Helper/ExcelCSVWriterWrapper.php (77)

Thanks Amit

thanksd
  • 54,176
  • 22
  • 157
  • 150
Amit Shah
  • 1,380
  • 1
  • 10
  • 19
  • I think [this answer](http://stackoverflow.com/a/25056427/5517143) will guide you in the right direction. – Rajdeep Paul Dec 08 '15 at 13:56
  • Have you read the PHPExcel documentation..... like the bit about [using cell caching to reduce memory usage](https://github.com/PHPOffice/PHPExcel/blob/develop/Documentation/markdown/Overview/04-Configuration-Settings.md)? – Mark Baker Dec 08 '15 at 14:10
  • @MarkBaker yes i read it earlier, but it didnt worked out for me. – Amit Shah Dec 09 '15 at 04:20
  • So what methods did you actually try? Simply saying "didn't work for me" tells me nothing. – Mark Baker Dec 09 '15 at 08:01
  • PHPExcel is constrained by PHP memory Limits... using cell caching can reduce the required memory for the script and the data but can't eliminate the need for memory entirely.... Are you simply trying to create a CSV file, or have you loaded another spreadsheet file? Do you have any large arrays in memory? What framework are you using? – Mark Baker Dec 09 '15 at 08:03
  • @MarkBaker i am just generating csv file, no new spreadsheet – Amit Shah Dec 09 '15 at 12:55
  • If all you're doing is generating a CSV file, then PHPExcel is heavy overkill..... just use PHP's built-in [fputcsv()](http://www.php.net/manual/en/function.fputcsv.php) function – Mark Baker Dec 09 '15 at 12:57
  • @MarkBaker Let me try to do that, Thanks – Amit Shah Dec 09 '15 at 12:59

0 Answers0