PHPExcel版本:1.7.6+

在不进行特殊设置的情况下,phpExcel将读取的单元格信息保存在内存中,我们可以通过PHPExcel_Settings::setCacheStorageMethod()来设置不同的缓存方式,已达到降低内存消耗的目的!

相关视频教程推荐:php入门教程

解决方案:

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教程

更多相关文章

  1. mall整合Redis实现缓存功能
  2. 10 行 Java 代码实现最近被使用(LRU)缓存
  3. Mybaitis缓存的优化
  4. MyBatis 延迟加载、一二级缓存、架构设计的面试题(常问,重点了解)
  5. 帮你解读什么是Redis缓存穿透和缓存雪崩
  6. MyBatis之Mapper XML 文件详解(六)-缓存配置
  7. redis缓存服务
  8. HTTP缓存

随机推荐

  1. android native c 的so调试
  2. android中对sim卡联系人的增删改查以及监
  3. Android 关闭/打开多点触控 (Android中设
  4. android 文字尺寸(宽高)的测量
  5. Android三种常用动画分享
  6. mac 系统中Android(安卓)studio的一些快
  7. Android实训(一)小记
  8. AndroidManifest.xml中uses-sdk配置详解
  9. Android基础--Fragment
  10. Android手机开发 控件 TextView文字居中