PhpSpreadsheet
PhpSpreadsheet copied to clipboard
Error retrieving formula result
This is:
- [X] a bug report
- [X] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)
What is the expected behavior?
Im reading a xlsx file column, this column contain a formula if y use getCalculatedValue() y wamt to receive the same value the spreadsheet has.
What is the current behavior?
i receive a different value
What are the steps to reproduce?
read the file with PhpSpreadsheet and get the cell K30 from the first sheet with the function getCalculatedValue()
Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:
<?php
require __DIR__ . '/vendor/autoload.php';
// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
// add code that show the issue here...
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader("Xlsx");
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load("Calculos sept-2013.xlsx");
$k = $spreadsheet->getActiveSheet()->getCell('K30')->getCalculatedValue();
echo "the var k contains: ".$k." and in the excel the cell K30 have 42";
### Which versions of PhpSpreadsheet and PHP are affected?
PhpSpreadsheet 1.14
Php 7.4.2
So what is the formula in cell K30? What is the value that you are getting when you call getCalculatedValue()? What are the values of cells that are reerenced in the formula?
Hello, thank you for your response, im going to attach the file DEMOXLSX.xlsx, the formula is like follow:
=SI(O(B30>1;B30=1);REDONDEAR(I30*(POTENCIA((1+$X$18/100);$U$17));0);"")
on the excel the result is 42 but in phpspreadsheet getCalculatedValue() return 13 DEMOXLSX.xlsx
So what is the formula in cell K30? What is the value that you are getting when you call
getCalculatedValue()? What are the values of cells that are reerenced in the formula?
Hello, thank you for your response, im going to attach the file DEMOXLSX.xlsx, the formula is like follow:
=SI(O(B30>1;B30=1);REDONDEAR(I30*(POTENCIA((1+$X$18/100);$U$17));0);"")
on the excel the result is 42 but in phpspreadsheet getCalculatedValue() return 13 DEMOXLSX.xlsx DEMOXLSX.xlsx
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue for you, please try to help by debugging it further and sharing your results. Thank you for your contributions.
Confirming - this is still a problem.