phpExcel大数据量情况下导出内存溢出解决

1、将单元格数据序列化后保存在内存中
PHPExcel_CachedObjectStorageFactory::cache_in_memory_serialized;
2、将单元格序列化后再进行Gzip压缩,然后保存在内存中
PHPExcel_CachedObjectStorageFactory::cache_in_memory_gzip;
3、缓存在临时的磁盘文件中,速度可能会慢一些
PHPExcel_CachedObjectStorageFactory::cache_to_discISAM;
4、保存在php://temp
PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
5、保存在memcache中

PHPExcel_CachedObjectStorageFactory::cache_to_memcache

注意是加在new PHPExcel() 前面:如下

 require_once APPPATH .'third_party/PHPExcel/PHPExcel.php';   
 $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_phpTemp;
 $cacheSettings = array('memoryCacheSize'=>'16MB');
 PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
 $objPHPExcel = new PHPExcel();

发表评论

电子邮件地址不会被公开。 必填项已用*标注