1
votes

The problem started in a very complex worksheet but I reduce it to a very simple but still having the same problem.

PHPExcel is not calculating the formula, but if I change to a simple one (=B3) it works.

The formula returned by getvalue() is

=IF(B3="","",IF(C8="N",IF(ISERR(VALUE(B3)),0,VALUE(B3)),T(B3)))

My code.

require_once dirname(__FILE__) . '/../phpxl/Classes/PHPExcel.php'; 
set_include_path(get_include_path() . PATH_SEPARATOR . '/../phpxl/Classes/'); 
$template = "test.xlsx"; 
$objReader = PHPExcel_IOFactory::createReader('Excel2007'); 
$objPHPExcel = $objReader->load($template); 
$objPHPExcel->getActiveSheet()->getCell('B3')->setValue(8); 
$result = $objPHPExcel->getActiveSheet()->getCell('B8')->getCalculatedValue(); 
$result1 = $objPHPExcel->getActiveSheet()->getCell('B8')->getValue(); 
echo $result.'<br>'; 
echo $result1.'<br>';

I'm setting a value of 8 at the B3 cell, doing this in excel calculates the same value at B8.

C8 has an 'N'.

But with phpexcel I always get the value it was saved with (2.1)

Response: 2.1 =IF(B3="","",IF(C8="N",IF(ISERR(VALUE(B3)),0,VALUE(B3)),T(B3)))

Replacing in the excel file the formula at B8 to '=B3' it works perfectly showing the result '8'.

Response: 8 =B3

So I must think that is a problem with the formula.

The functions are quite simple IF, T, VALUE, ISERR.

Change all double quotation and the issue persists.

=IF(ISBLANK(B3),NA(),IF(C8="N",IF(ISERR(VALUE(B3)),0,VALUE(B3)),T(B3))) 

Any idea to get a workaround to this will be welcome.

Tks

1

1 Answers

1
votes

That's because (as listed in the documentation) the VALUE() function has not yet been implemented in the PHPExcel calculation engine