使用PhpExcel编写xls(xlsx)文件时出现内存问题。我曾尝试使用缓存,但在编写新文档时似乎不起作用。
$cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_to_phpTemp;
$cacheSettings = array( 'memoryCacheSize' => '8MB'
);
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
库更新到当前版本(v1.8.1)后,问题有所改善,但我仍然可以准备和导出一个包含8列和15000 - 20000行的文件(20000行cache_in_memory_gzip
)而不增加内存限制。不幸的是,在我的情况下,这不是充分的解决方案。
缓存方法可能允许我提前准备更多条目,但在实际写入方法期间似乎无关紧要。
$file = new PHPExcel();
// Prepare data ...
$writer = PHPExcel_IOFactory::createWriter($file, 'Excel2007');
$writer->save($pathname); // More memory required