phpExcel如何将设置传递给类

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了phpExcel如何将设置传递给类脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
基本上我试图启用单元格缓存由于内存问题(不断耗尽)其相当大的sPEadsheet.从我在网上看到的细胞缓存是一个很好的方法

从我在网上找到的例子看起来像这样

Cell caching and memory leak

stackoverflow – fix memory error

$oExcel = new PHPExcel();
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_PHPTemp;
$cacheSettings = array( 'memoryCacheSize' => '512MB');

PHPExcel_Settings::setCacheStorageMethod($cacheMethod,$cacheSettings);

上面的问题是我没有设置excel对象的设置?

$oExcel->setCacheStorageMethod($cacheMethod,$cacheSettings); // this returns method not found error

我想我只是初步错了吗?

@H_403_28@解决方法
它在开发人员文档的4.2.1节中描述:标题为“Cell Caching”的部分;并且您需要在实例化或加载PHPExcel对象之前设置单元格缓存.

setCacheStorageMethod()不是PHPExcel类的方法,因为您尝试在此行中使用:

$oExcel->setCacheStorageMethod($cacheMethod,$cacheSettings);

使用

$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_PHPTemp;
$cacheSettings = array( 'memoryCacheSize' => '512MB');
PHPExcel_Settings::setCacheStorageMethod($cacheMethod,$cacheSettings);

$oExcel = new PHPExcel();

并且新的PHPExcel对象将自动使用配置的缓存设置(即PHPtemp)

脚本宝典总结

以上是脚本宝典为你收集整理的phpExcel如何将设置传递给类全部内容,希望文章能够帮你解决phpExcel如何将设置传递给类所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。