参见英文答案 > PHPExcel runs out of 256, 512 and also 1024MB of RAM 7个
我正在使用phpexcel编写相当大的excel文件.
我是从一个看起来像的数组中写的
array(
[0] => stdClass Object
(
[sent] => Mar 31st, 2011 02:10PM
[to_number] => 64211111111
[additional_txt] =>
[misc_data] =>
)
...
[14058] => stdClass Object
(
[sent] => Mar 31st, 2011 02:10PM
[to_number] => 64211111111
[additional_txt] =>
[misc_data] =>
)
)
循环是
$r = 0;
foreach ($replies_obj as $row) {
$c = 'A';
foreach ($row as $col)
$xlsx->getActiveSheet()->setCellValue($c++ . $r, $col);
$r++;
}
而错误是
Fatal error: Allowed memory size of
134217728 bytes exhausted (tried to
allocate 105 bytes) in
/home/webspace/xxxx/test/htdocs/application/libraries/PHPExcel/Worksheet.php
on line 961
这是一个phpexcel问题还是我做错了什么?
我怎样才能解决这个问题?
解决方法:
有很多关于PHPExcel和内存使用的文章,我不打算在这里重复一遍.
尝试阅读讨论该问题的PHPExcel讨论板上的一些线程,例如this one;或者之前的答案,例如this one或this one