Error when writing with links to numeric worksheets.

Topics: Developer Forum, User Forum
Mar 3, 2011 at 12:17 AM

Let's say I have two worksheets, "Sheet1" and "2" in an Excel5 xls file.

 

Worksheet "Sheet1" has a cell that links to another cell in the worksheet "2", and thus the formula for the Sheet1 cell looks like: '2'!A1

 

When reading and then writing this worksheet (whether you do any other work or not does not matter), it generates the following error:

Fatal error: Uncaught exception 'Exception' with message 'Sheet1!A1 -> Sheet1!A1 -> Cyclic Reference in Formula' in <path to install>\PHPExcel\Cell.php:288
Stack trace:
#0 <path to install>\PHPExcel\Writer\Excel5\Worksheet.php(441): PHPExcel_Cell->getCalculatedValue()
#1 <path to install>\PHPExcel\Writer\Excel5.php(171): PHPExcel_Writer_Excel5_Worksheet->close()
#2 <path to install>\test.php(10): PHPExcel_Writer_Excel5->save(NULL)
#3 {main}  thrown in <path to install>\PHPExcel\Cell.php on line 288

 

If you just add more letters AFTER the numbered worksheet name, like "2hot", it generates this error:

Fatal error: Call to a member function cellExists() on a non-object in <path to install>\PHPExcel\Calculation.php on line 3209

 

If you add letters BEFORE the number, like "hot2" (or the default "Sheet2"), it does not generate errors. (Interestingly, you can also add a blank space before or after the bare number, and it will also avoid the errors.)