Urgent: SetTitle does not work on PHP 5.4.0beta1

Topics: Developer Forum, User Forum
Nov 7, 2011 at 4:24 PM

Hello Folks!

I kept developing locally using XAMPP with PHP version 5.3.8 and things were working just fine. However, I now deployed my code to a 1&1 hosting account running  PHP 5.4.0beta1 and the Excel export stopped working. I keep receiving a LogicException when I try to set a title for a new worksheet. I also tried adding a call of the parent constructor in the WorksheetIterator, but that also did not work. It seems like PHP does not use the default constructor in the CachedIterator class anymore.

Fatal error: Uncaught exception 'LogicException' with message 'In the constructor of PHPExcel_WorksheetIterator, parent::__construct() must be called and its exceptions cannot be cleared' in /.../classes/PHPExcel.php:515 Stack trace: #0 /.../classes/PHPExcel.php(515): PHPExcel_WorksheetIterator->internal_construction_wrapper(Object(PHPExcel)) #1 /.../classes/PHPExcel/ReferenceHelper.php(530): PHPExcel->getWorksheetIterator() #2 /.../classes/PHPExcel/Worksheet.php(693): PHPExcel_ReferenceHelper->updateNamedFormulas(Object(PHPExcel), 'Worksheet 1', 'Name of Worksheet') #3 /.../ExcelExport.php(286): PHPExcel_Worksheet->setTitle('Name of Worksheet')

Any help would be highly appreciated!


Nov 8, 2011 at 9:31 AM

Hey Folks,

I manged to make it work again, but the generated Excel spreadsheet is corrupted. To make it run under PHP 5.4.0beta1 you have to modify the PHPExcel_WorksheetIterator class. Currently, it extends the CachingIterator which constructor has been changed in the PHP beta. To make the code run, you can change the class definition to: "implements Iterator" instead of "extends CachingIterator". As I said, the generated file will be corrupt, but it is possible to open it in Excel using the repair functionality, see: https://office.microsoft.com/en-us/excel-help/repairing-corrupted-files-in-excel-HA001034656.aspx