Change input value but not change result in PhpExcel -


i have got problem phpexcel below function

function test($a, $b) {      //  create new phpexcel object single sheet     $objphpexcel = new phpexcel();     $activesheet = $objphpexcel->getactivesheet();      $activesheet->setcellvalue('b2',$a);     $activesheet->setcellvalue('b3',$b);     $activesheet->setcellvalue('c4',"=b2+b3");     $c4 = $activesheet ->getcell('c4')->getcalculatedvalue();      echo "c4:$c4<br/>"; } 

finally, call function

test(10, 20); test(40, 70); test(30, 80); 

but, result is

c4:30 c4:30 c4:30  

why getcalculatedvalue() doesn't change result? seems function gets first value.

you can change result, performance reasons calculation engine caches result of formula calculation once it's been calculated. if want change underlying data, have flush cache before requesting calculated value again:

phpexcel_calculation::getinstance()->clearcalculationcache(); 

or

phpexcel_calculation::flushinstance(); 

you can change default behaviour - results not cached @ - before issuing other requests calculation engine:

phpexcel_calculation::getinstance()->setcalculationcacheenabled(false); 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -