I am using PHPExcel library: https://github.com/PHPOffice/PHPExcel
I whant to set a formula for the C1 cell:
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 5)
->setCellValue('B1', 6)
->setCellValue('C1', "=SUM(A1,B1)");
That works fine.
Once I change the formula to one that has + or - operators, for example:
->setCellValue('C1', "=A1-B1");
instead of
->setCellValue('C1', "=SUM(A1,B1)");
I get the following error:
Illegal string offset 'value' in \phpexcel\PHPExcel\Calculation.php on line 2976
and then
Array to string conversion in \phpexcel\PHPExcel\Calculation.php on line 3010
Looking at the Calculation.php code - I find out that it cuts the references A1 and B1 to A and B.
Any idea how to fix it? Thank you!
Remark1: Looks like it doesn't matter but I prefer to mention that I have a spanish version of Excel installed on the computer.
Remark2: In the examples I found on PHPExcel GitHub all the formulas don't have operators, only functions are used.
=E11+E12as well as=E11*0.21and more complex formulas with operators such as=IF(D6<>"",C6*D6,"")- Mark BakerA1:B1), but doesn't accessvaluein any way (although line 2974 does) - Mark Baker