0

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?

doovers
  • 8,545
  • 10
  • 42
  • 70
  • Increase memory limit. But don't set it to -1. Set it to a large enough value so errors go away. – B-and-P Sep 26 '14 at 04:02
  • You can try to read in the file in chunks. Take a look at this [answer](http://stackoverflow.com/a/4666824/1144203). – ivan.sim Sep 26 '14 at 04:10
  • PHPExcel is memory intensive . You can write your own code to export as a .csv file if that is okay with you . – Uours Sep 26 '14 at 04:47
  • If you need BIFF format rather than CSV format, look at the methods that PHPExcel has for reducing memory usage, such as cell caching – Mark Baker Sep 26 '14 at 06:57

2 Answers2

0

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/

prince
  • 1,129
  • 1
  • 15
  • 38
0

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

ButterflyRay
  • 395
  • 2
  • 11