1

When I enable the cache options to improve memory usage:

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

I get a fatal error:

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

Is there a way to fix this error?

pnuts
  • 58,317
  • 11
  • 87
  • 139
xmarston
  • 853
  • 3
  • 12
  • 36
  • Assuming that you're using version 1.7.9; Is this still a problem with the new version 1.8.0 that fixed some SimpleXMLElement problems with the xlsx reader – Mark Baker Mar 04 '14 at 23:06
  • @MarkBaker yes, upgraded to 1.8.0 and I get the same message. – xmarston Mar 05 '14 at 06:43
  • Can you provide a sample spreadsheet file that demonstrates this problem, or indicate what application and version was used to create the file – Mark Baker Mar 05 '14 at 08:02
  • @MarkBaker I can't provide you a sample spreadsheet because it is confidential but the file was created in Excel 2007, it is an xlsx file. – xmarston Mar 05 '14 at 08:30
  • That sadly doesn't narrow it down much at all, because I test against hundreds of xlsx files; but you're certain that it was created using MS Excel version 2007 (not simply because of the file extension?) – Mark Baker Mar 05 '14 at 08:34
  • If I use new PHPExcel_Reader_Excel5() it shows a message error "The filename XXX.xlsx is not recognised as an OLE file", so I gather that was created with MS Excel 2007. – xmarston Mar 05 '14 at 09:15
  • The fact that PHPExcel recognises the file as one to read using the Excel2007 Reader doesn't mean that it was actually created using MS Excel 2007. PHPExcel can't identify what application was used to create a file - MS Excel, Gnumeric, Libre/Open Office, Apache POI, etc can all create OfficeOpenXML .xlsx files (which required the Excel2007 Reader) or BIFF .xls files (which require the Excel5 Reader): only what format it is supposed to be (OfficeOpenXML or BIFF). And unfortunately, different applications don't always adhere exactly to the defined standard for the recognised file format. – Mark Baker Mar 05 '14 at 09:28
  • I'm 99% sure that it was created in MS Excel 2007. – xmarston Mar 05 '14 at 09:32

1 Answers1

0

I have the same problem. My file is confidential too :/. But I have found in MemoryGZip.php, before this line

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

the value of $this->_currentObject is

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)
    )

)

Other cells of this column with the same formula, which are processed without problems, have not this block

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

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

Hope it will help to identify problem. PS Mark, thank you for PHPExcel.

Andrew
  • 21
  • 3