-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Hello everyone !
This is a bug report or a bad use of a function but i didn't find any information about that.
What is the expected behavior?
I have a xlsm file with a cell with a formula ( "=SI(D$11=0;0;D133+D123)"), and this function is supposed to return a float.
What is the current behavior?
This is my error :
Fatal error : Uncaught PhpOffice\PhpSpreadsheet\Calculation\Exception: SUMMARY!D136 -> SUMMARY!D133 -> SUMMARY!D116 -> SUMMARY!D113 -> Formula Error: An unexpected error occured in C:\xampp\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Cell\Cell.php:274
Stack trace:
#0 C:\xampp\htdocs\api\spreadsheets\readFBIFile.php(54): PhpOffice\PhpSpreadsheet\Cell\Cell->getCalculatedValue()
#1 C:\xampp\htdocs\redirection.php(318): include('C:\xampp\htdocs...')
#2 {main}
thrown in C:\xampp\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Cell\Cell.php on line 274
When i use the function getCalculatedFormula on this cell i have an uncaught error. If i follow the error, it's stop on this formula :
=SI(D$11=0;0;INDEX(PRICES!$201:$207;EQUIV(D7/1000;PRICES!$B$201:$B$207;1);EQUIV(D5;PRICES!$201:$201;0)))*PRICES!$C$248 />
PRICES is an other sheet.
What are the steps to reproduce?
$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$reader->setReadDataOnly(true);
$reader->setLoadSheetsOnly(["SUMMARY","INPUT","PRICES"]);
$temp= array();
$alphas = range('A', 'Z');
$spreadsheet = $reader->load($_FILES['file']['tmp_name']);
$lettre ='D';
$nombre=10;
$value = $spreadsheet->getSheet(0)->getCell($lettre.$nombre)->getCalculatedValue();
while(is_float($value)){
array_push($temp,array("Masse" => $value));
++$lettre;
$value = $spreadsheet->getSheet(0)->getCell($lettre.$nombre)->getCalculatedValue();
}
$lettre ='D';
$nombre=11;
for($i=0;$i<=count($temp)-1;$i++){
$value = $spreadsheet->getSheet(0)->getCell($lettre.$nombre)->getCalculatedValue();
$temp[$i]['quantite']=$value;
++$lettre;
}
$lettre ='D';
$nombre=136;
// The problem start here. Before this line, all works.
for($i=0;$i<=count($temp)-1;$i++){
$value = $spreadsheet->getSheet(0)->getCell($lettre.$nombre)->getCalculatedValue();
$temp[$i]['prix']=$value;
++$lettre;
}
echo var_dump($temp);I can't upload my excel file because it's a company file, so i have to wait the autorisation. But i want to know if a function of the formula is a known problem.
Which versions of PhpSpreadsheet and PHP are affected?
I use PhpSpreadSheet 1.4.0 and PHP 7.2.9.