0
votes

I'm trying to export a large mysql table (~25000 rows) to excel using phpexcel. But when I run the query to pull the data from the database, I get the following error:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 64 bytes)

I would assume I should change my memory_limit value but I don't know what a reasonable value for this should be and I know that something like:

ini_set('memory_limit', -1);

is not a good idea...

What's the best approach to this situation?

2
Increase memory limit. But don't set it to -1. Set it to a large enough value so errors go away.B-and-P
You can try to read in the file in chunks. Take a look at this answer.ivan.sim
PHPExcel is memory intensive . You can write your own code to export as a .csv file if that is okay with you .Uours
If you need BIFF format rather than CSV format, look at the methods that PHPExcel has for reducing memory usage, such as cell cachingMark Baker

2 Answers

0
votes

I'm sorry for my English (I speak Spanish) You could use excel for MySQL and do what you want

You can refer the following link

http://www.mysql.com/why-mysql/windows/excel/

0
votes

Did you try phpmyadmin? I have used phpmyadmin to export a table with around 12000 records to excel sheet..