Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught error with getCalculatedValue #677

Closed
umadgen opened this issue Sep 18, 2018 · 1 comment
Closed

Uncaught error with getCalculatedValue #677

umadgen opened this issue Sep 18, 2018 · 1 comment
Labels

Comments

@umadgen
Copy link

umadgen commented Sep 18, 2018

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.

@stale
Copy link

stale bot commented Nov 17, 2018

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.

@stale stale bot added the stale label Nov 17, 2018
@stale stale bot closed this as completed Nov 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant