I'm trying to select data from the database and write them to Excel file using PHPExcel_IOFactory. The script ends with the following error
PHP Fatal error: Uncaught exception 'PHPExcel_Calculation_Exception' with message 'Worksheet!AC2064 -> Formula Error: Unexpected operator '>'' in F:\SVN\Migration\CommonLib\CodePlex\PHPExcel\Cell.php:298
I tried to escape all cells one by one and also replace this character with blank space which resulted in unknown exception
$lineNumber = 2;
while($row = odbc_fetch_array($result)){
try{
//print_r($row);
$row = EscapeArray($row);
$document->getActiveSheet()->fromArray($row, null, "A" . $lineNumber);
$lineNumber++;
} catch(Exception $e){
echo "Caught exception: " . $e->getMessage() . "\n";
}
}
$writter = PHPExcel_IOFactory::createWriter($document, 'Excel2007');
$writter->save($tempFilePath);
function EscapeArray($array){
$output = array();
foreach($array as $key => $value){
$output[$key] = addslashes($value);
}
return $output;
}
I would like to figure out why does the '<' character causing the error and how to fix it. Many thanks in advance.