解決方案:
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;
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_memcache; $cacheSettings = array( 'memcacheServer' => 'localhost', 'memcachePort' => 11211, 'cacheTime' => 600 ); PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
注意是加在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();
推薦相關文章教學:php教學
以上就是phpexcel匯入巨量資料記憶體溢位的解決方法有哪些的詳細內容,更多請關注TW511.COM其它相關文章!