illegal character crash the export

Topics: Developer Forum, User Forum
Feb 14, 2012 at 2:57 AM

If user type ) in database, the export will be crash, how to solve this problem?

The crash message:
 
<br /><b>Fatal error</b>:  Uncaught exception 'Exception' with message 'Worksheet!L5 -&gt; Formula Error: Unexpected ')'' in /home/httpd/vhosts/event88.com.tw/httpdocs/2011prune/libs/PHPExcel/Cell.php:288Stack trace:#0 /home/httpd/vhosts/event88.com.tw/httpdocs/2011prune/libs/PHPExcel/Writer/Excel5/Worksheet.php(441): PHPExcel_Cell-&gt;getCalculatedValue()#1 /home/httpd/vhosts/event88.com.tw/httpdocs/2011prune/libs/PHPExcel/Writer/Excel5.php(171): PHPExcel_Writer_Excel5_Worksheet-&gt;close()#2 /home/httpd/vhosts/event88.com.tw/httpdocs/2011prune/admin/kaka_list.php(103): PHPExcel_Writer_Excel5-&gt;save('php://output')#3 {main}  thrown in <b>/home/httpd/vhosts/event88.com.tw/httpdocs/2011prune/libs/PHPExcel/Cell.php</b> on line <b>288</b><br /> 

Feb 14, 2012 at 8:15 AM

apparantly phpExcel thinks that the cell contains a formula. Obviously a formula with a single ( is not valid. I would suggest explicitly settings celltype to string, or disabling formulae

Feb 14, 2012 at 8:19 AM

It's work, thanks for your suggestion :)

I set the celltype to string, but could you tell how to disable the formulae

Coordinator
Feb 14, 2012 at 10:46 PM

Under normal circumstances, PHPExcel should only treat a cell value as a formula if it starts with an equals (=) character, as does Excel itself. This behaviour is controlled when setting a cell value by the DefaultValueBinder. If you're loading data from a database, then this is the rule that should apply.

When reading from a workbook file, the readers use setValueExplicit based on the datatyping in the loaded workbook file. For CSV files (and other formats that don't identify a datatype explicitly), the ValueBinder rules apply.

Sep 25, 2012 at 9:15 AM
chan15 wrote:

If user type ) in database, the export will be crash, how to solve this problem?

The crash message:
 
<br /><b>Fatal error</b>:  Uncaught exception 'Exception' with message 'Worksheet!L5 -&gt; Formula Error: Unexpected ')'' in /home/httpd/vhosts/event88.com.tw/httpdocs/2011prune/libs/PHPExcel/Cell.php:288Stack trace:#0 /home/httpd/vhosts/event88.com.tw/httpdocs/2011prune/libs/PHPExcel/Writer/Excel5/Worksheet.php(441): PHPExcel_Cell-&gt;getCalculatedValue()#1 /home/httpd/vhosts/event88.com.tw/httpdocs/2011prune/libs/PHPExcel/Writer/Excel5.php(171): PHPExcel_Writer_Excel5_Worksheet-&gt;close()#2 /home/httpd/vhosts/event88.com.tw/httpdocs/2011prune/admin/kaka_list.php(103): PHPExcel_Writer_Excel5-&gt;save('php://output')#3 {main}  thrown in <b>/home/httpd/vhosts/event88.com.tw/httpdocs/2011prune/libs/PHPExcel/Cell.php</b> on line <b>288</b><br /> 

 

you can use setCellValueExplicit