How to fix Fatal Error PHPExcel: Memory Limit Exhausted while reading XLSX file of 5M
I am facing this problem while reading an XLSX files having 40,000 plus rows and 7 columns having 5MB+ file size with PHPExcel.
The error description is given here:
Can you please suggest me a solution to this problem?
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 32 bytes) in .....
Thanking you in anticipation.
You can change the max memory allotment via the memory_limit setting, either via ini_set() in the script, or in an applicable config file.
Personally, I'd look for a way to process one line at a time instead of trying to load it all into memory, if that is practical. One way would be to save the Excel file as a CSV file, then use fopen() and fgetcsv() to read that CSV file one line at a time, processing each line individually.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
How to Ask Questions the Smart Way
(not affiliated with this site, but well worth reading)
Already Memory Limit Updated
Thanks for the reply. I have already tried the first solution i.e. changing memory_limit in php.ini But it stil does not work even setting the memory_limit= 512M.
Originally Posted by NogDog
However, I will look for the 2nd solution that you have just suggested using fopen() with CSV.
Looking forward. Hope to hear from you soon.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread