formula results in zero

Topics: User Forum
Jan 24, 2008 at 10:03 AM
I have this piece of code:

include 'PHPExcel.php';
include 'PHPExcel\Reader\Excel2007.php';
require_once 'PHPExcel\Calculation.php';

$objReader = new PHPExcelReaderExcel2007();
$objPHPExcel = $objReader->load("03formulas.xlsx");
echo 'Value of B5: ' . $objPHPExcel->getActiveSheet()->getCell('B5')->getCalculatedValue();

I'm trying to read the results of a formula in cell B5 from one of the supplied example files. It's Excel2007 format so there shouldn't be a problem with formula's and calculation.
But the result is always zero. De formula doesn't calculate. What did I do wrong?
Jan 24, 2008 at 2:45 PM
You spotted a bug! Will create a bug fix for this...
Jan 24, 2008 at 2:55 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Jan 24, 2008 at 3:38 PM
Thanks for the fix. I didn't know which file changed so I donwloaded all files in SVN, replaced the current ones.
Works as expected now. Thanks!
Just out of curiosity: what bug did you fix where?
Jan 24, 2008 at 4:38 PM
The Excel reader was reading in numeric values as string. Since the calculation engine uses int/float/double for calculation, and ignores strings, all values read by Excel reader where treated as string in the calculation engine, resulting in 0 as the sum.