phpexcel 允许的内存大小为 134217728 字节已用完 [英] phpexcel Allowed memory size of 134217728 bytes exhausted
问题描述
我正在使用 phpexcel 编写相当大的 excel 文件.
I am using phpexcel to write quite a large excel file.
我正在从一个看起来像
I am writing it from an array that looks like
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++;
}
而错误是
致命错误:允许的内存大小为134217728 字节已用完(试图分配 105 个字节)在/home/webspace/xxxx/test/htdocs/application/libraries/PHPExcel/Worksheet.php在线961
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的问题还是我做错了什么?
Is this a phpexcel problem or am I doing something wrong?
我该如何解决这个问题?
How can I fix this?
推荐答案
有很多关于 PHPExcel 和内存使用的文章,我不打算在这里重复.
There's a lot been written about PHPExcel and memory use, and I'm not going to repeat it all here.
尝试阅读 PHPExcel 讨论板上讨论该问题的一些主题,例如 这个;或以前关于 SO 的答案,例如 this one 或 这个
Try reading some of the threads on the PHPExcel discussion board discussing the issue, such as this one; or previous answers here on SO such as this one or this one
这篇关于phpexcel 允许的内存大小为 134217728 字节已用完的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!