Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.9.4

Bug #10399 Fatal error when closing workbook with no worksheets.
Submitted: 2007-03-16 09:05 UTC
From: leifmusik Assigned: cweiske
Status: Closed Package: Spreadsheet_Excel_Writer (version 0.9.1)
PHP Version: 5.0.5 OS: Windows XP
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 29 - 24 = ?

 
 [2007-03-16 09:05 UTC] leifmusik (Leif Mallon)
Description: ------------ When a Workbook is created with new Spreadsheet_Excel_Writer() but no worksheets are added and you try to close the workbook, then the following fatal error is produced: You normally don't do these kind of things, but i encapsuled the functionality in a class and came to this situation during tests. Reason: In file Workbook.php function _storeWorkbook() the following code ininitializes the worksheets array even if no worksheets exist: // Ensure that at least one worksheet has been selected. if ($this->_activesheet == 0) { $this->_worksheets[0]->selected = 1; } Possible solution: Before the above mentioned code test for existing worksheets and exit function if no worksheets exist: // If no worksheets exist, return. if (count($this->_worksheets) == 0) { return true; } Test script: --------------- $xls =& new Spreadsheet_Excel_Writer(); $xls->close(); Expected result: ---------------- At least nothing. Actual result: -------------- Fatal error: Call to undefined method stdClass::close() in C:\PHP\PEAR\Spreadsheet\Excel\Writer\Workbook.php on line 510

Comments

 [2007-03-27 14:06 UTC] cweiske (Christian Weiske)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.