Formulas display as zeros (0) when using 2007 Writer (PHPExcel 1.8.0, PHP 5.6.3)

Topics: Developer Forum
Feb 17, 2015 at 2:25 PM
Edited Feb 17, 2015 at 3:29 PM
I'm not sure when this started happening but I assume it was when I upgraded PHPExcel and PHP on my servers.

This was working before, but now when I try to use the 2007 writer to create an .xlsx file, all of the formulas are displaying zero. They will correct themselves if I update the field with slightly different information (start at B2 instead of B1 for instance) and this is across LibreOffice, Mac Preview, OpenOffice, and Word 2013. The Word 2013 users have gotten around it by re-saving the file from their app and re-opening it, then the formulas display correctly.

Simple example below:
/ A3 will display as 0 instead of 30, and when it does display, it's left aligned, might be a clue /
include 'PHPExcel.php';
include 'PHPExcel/IOFactory.php';
$EXCEL = new PHPExcel();
$SHEET = $EXCEL->getActiveSheet();

$SHEET->setCellValue('A1', '10');
$SHEET->setCellValue('A2', '20');
$SHEET->setCellValue('A3', '=(A1+A2)');

$WRITER = PHPExcel_IOFactory::createWriter($EXCEL, 'Excel2007');
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="test.xlsx"');
header('Cache-Control: max-age=0');
Feb 17, 2015 at 3:29 PM
I just tried with my last rev of PHPExcel which was 1.7.1 and the problem persists, so it's something to do with PHP 5.6.3 (formerly I was on 5.2.17).

Later today I'll try turning Warnings on on the logging and see if anything jumps out at me.