'Formula Error: An unexpected error occured

Topics: Developer Forum
Jun 2, 2010 at 11:43 PM
Edited Jun 2, 2010 at 11:45 PM

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:

   =IF(A1>0,"SI","NO")

Shouldn't it work in both cases?

Thanks!

Coordinator
Jun 3, 2010 at 8:46 PM

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