Recently in helping a company to do the background Excel export function, the use of the tool class is phpexcel, because this kind of function is more powerful, comprehensive.
However, you encounter one of the following problems:
When the amount of data exported to a certain number of times, such as 1000, the server is stuck, white screen phenomenon, if you increase the number of exports, there is a 502 error gateway hint.
After Baidu, some domestic forum for the investigation,
The following measures are drawn:
1. Set the PHP cache
//Set Caching method Phpexcel_settings::setcachestoragemethod ();
2. Set Maximum execution time
// set maximum execution time Set_time_limit (0);
However, after debugging, it did not work, still reported 502 errors.
Finally, after looking at the memory information, I turned the problem source recovery into memory, so I made the following settings:
// Setting Memory Limits Ini_set (' Memory_limit ', ' 256M ');
Next is the excitement of the result, Excel successfully exported!
At this point, the problem has been resolved.
Phpexcel is a powerful class, but there is a lot of room for improvement in performance optimization, and hopefully in the near future a lightweight Excel usage class can be introduced ^_^
About the Phpexcel class consuming memory issues