I had the same problem. You will need to allocate enough time and limit memory.
I tested my solution on 3 different servers, here is the result:
About 5000 records (12 columns)
Reading file:
09:48:22 peak memory usage: 1.25 MB
Reading data:
09:48:31 Peak Memory Usage: 54.5 MB
After indexing the data into an array:
09:48:35 peak memory usage: 68.5 MB
Records: 4504
I increased my memory and time to read 22,000 records after indexing, to 370.00 MB.
Here is the solution (assuming everything else is correct in the code sequence) where you call PHPExcel in your program / function:
ini_set("max_execution_time", 'time_limit');
Do all the initialization here so that all objects are ready, then allocate memory to read the file and index the data into the internal structure of the program:
ini_set('memory_limit', '???'); //your memory limit as string $excel = $excelReader->load($filePath); "Memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" //do the rest of the structure!
Itโs a good idea that all of this managed to manage some categories of data, so you donโt start at 400 MB - GRANT ERRORS!
Vlad
source share