'Formula Error: An unexpected error occured

Topics: Developer Forum
Jun 3, 2010 at 12:43 AM
Edited Jun 3, 2010 at 12:45 AM

Hi, It took me the whole day to figure out what the problem was with this exception.

I am trying to make a class which converts the html output of JQuery.Sheet into an XSLS or XSL file. 

This plugin outputs formulas as follows:

   <TD id="table0_cell_c1_r0" formula="=IF(A1 > 4, 'SI', 'NO')">NO</TD>

wich I filter out to this: 

   =IF(A1 > 4, 'SI', 'NO') 

And then I insert it in the corresponding cell.

At save time I end up with this Exception: 

Fatal error: Uncaught exception 'Exception' with message 'Formula Error: An unexpected error occured' in /var/www/JQSh2Excel/libs/Classes/PHPExcel/Calculation.php:2088 Stack trace:

#0 /var/www/JQSh2Excel/libs/Classes/PHPExcel/Cell.php(285): PHPExcel_Calculation->calculateCellValue(Object(PHPExcel_Cell), true)

#1 /var/www/JQSh2Excel/libs/Classes/PHPExcel/Writer/Excel5/Worksheet.php(436): PHPExcel_Cell->getCalculatedValue()

#2 /var/www/JQSh2Excel/libs/Classes/PHPExcel/Writer/Excel5.php(162): PHPExcel_Writer_Excel5_Worksheet->close()

#3 /var/www/JQSh2Excel/JQShtXML2Excel.php(110): PHPExcel_Writer_Excel5->save('out.xslx')

#4 /var/www/JQSh2Excel/index.php(22): JQShtXML2Excel->saveXSL('out.xslx')

#5 {main} thrown in /var/www/JQSh2Excel/libs/Classes/PHPExcel/Calculation.php on line 2088


But, replacing \' for \" works:


Shouldn't it work in both cases?


Jun 3, 2010 at 9:46 PM

It shouldn't work in both cases. MS Excel will error if you use ' but accepts "