include 'PHPExcel/IOFactory.php';
include 'PHPExcel.php';
$reader = PHPExcel_IOFactory::createReader('Excel2007');
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_memcache;
$cacheSettings = array( 'memcacheServer'=> 'localhost',
'memcachePort' => 11211,
'cacheTime' => 600 );
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings); $PHPExcel = PHPExcel_IOFactory::load("2013-06-13.xls");
$sheet = $PHPExcel->getSheet(0);
为什么加载只能读取一个文档,换个文件名就报Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1056 bytes) in G:\zhengli\PHPExcel\Cell.php on line 1131错误呢
求解答
include 'PHPExcel.php';
$reader = PHPExcel_IOFactory::createReader('Excel2007');
$cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_memcache;
$cacheSettings = array( 'memcacheServer'=> 'localhost',
'memcachePort' => 11211,
'cacheTime' => 600 );
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings); $PHPExcel = PHPExcel_IOFactory::load("2013-06-13.xls");
$sheet = $PHPExcel->getSheet(0);
为什么加载只能读取一个文档,换个文件名就报Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1056 bytes) in G:\zhengli\PHPExcel\Cell.php on line 1131错误呢
求解答
phpexcel 为了缓解他极耗内存的弱点,设置了多种缓存中间数据的方案。你可以根据你的情况选用他们
相关教程网上有,自己摸索一下也不难
$cacheSettings = array( 'memcacheServer'=> 'localhost',
'memcachePort' => 11211,
'cacheTime' => 600 );
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
但是还是不行啊,设置了缓存它还是不能读取别的文档
你是内存不够用才用缓存的,memcache 不也要占用内存吗?这样一来你的php可用内存不就更少了吗?