1

当我启用缓存选项以提高内存使用率时:

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

我收到一个致命错误:

Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in /Applications/MAMP/htdocs/XXXX/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php:65 Stack trace: #0 /Applications/MAMP/htdocs/XXXX/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php(65): serialize(Object(PHPExcel_Cell)) #1 /Applications/MAMP/htdocs/XXXX/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php(85): PHPExcel_CachedObjectStorage_PHPTemp->_storeData() #2 /Applications/MAMP/htdocs/XXXX/Classes/PHPExcel/Worksheet.php(1136): PHPExcel_CachedObjectStorage_PHPTemp->addCacheData('BN21', Object(PHPExcel_Cell)) #3 /Applications/MAMP/htdocs/XXXX/Classes/PHPExcel/Reader/Excel2007.php(881): PHPExcel_Worksheet->getCell('BN21') #4 /Applications/MAMP/htdocs/XXXX/engine.php(85): PHPExcel_Reader_Excel2007->load('XXXX.xlsx') #5 {main} thrown in /Applications/MAMP/htdocs/XXXX/Classes/PHPExcel/CachedObjectStorage/PHPTemp.php on line 65

有没有办法解决这个错误?

4

1 回答 1

0

我也有同样的问题。我的文件也是机密的:/。但我在 MemoryGZip.php 中找到,在此行之前

$this->_cellCache[$this->_currentObjectID] = gzdeflate(serialize($this->_currentObject));

$this->_currentObject 的值是

PHPExcel_Cell Object
(
[_value:PHPExcel_Cell:private] => =J4=SUM(K4:Q4)
[_calculatedValue:PHPExcel_Cell:private] => 1
[_dataType:PHPExcel_Cell:private] => f
[_parent:PHPExcel_Cell:private] => 
[_xfIndex:PHPExcel_Cell:private] => 5
[_formulaAttributes:PHPExcel_Cell:private] => SimpleXMLElement Object
    (
        [@attributes] => Array
            (
                [t] => shared
                [ref] => U4:U15
                [si] => 1
            )

        [0] => J4=SUM(K4:Q4)
    )

)

该列的其他具有相同公式的单元格,处理没有问题,没有这个块

[_formulaAttributes:PHPExcel_Cell:private] => SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [t] => shared
            [ref] => U4:U15
            [si] => 1
        )

    [0] => J4=SUM(K4:Q4)
)

希望这将有助于识别问题。PS马克,谢谢你的PHPExcel。

于 2015-10-21T07:34:33.467 回答