Jan 18, 2009 at 7:56 PM
Edited Jan 18, 2009 at 8:02 PM


I have:
cell C20 = 20
and cell C21 = 22

I show the data with: 
<?php echo ($objPHPExcel->getActiveSheet()->getCell('C20')->getCalculatedValue()); ?>
<?php echo ($objPHPExcel->getActiveSheet()->getCell('C21')->getCalculatedValue()); ?>

But how can i get C20+C21 ??

Sorry for my bad english.
Jan 18, 2009 at 9:17 PM
You do what you'd do in Excel
Set a third cell (e.g. D21) to be "=C20+C21"
Then echo ($objPHPExcel->getActiveSheet()->getCell('CD01)->getCalculatedValue());

You don't need 
echo ($objPHPExcel->getActiveSheet()->getCell('C20')->getCalculatedValue());
for cells C20 and C21 because you're not calculating them, so you could use
echo ($objPHPExcel->getActiveSheet()->getCell('C20')->getValue());
Jan 18, 2009 at 10:03 PM

Thanks markbaker!!

but Can i dont make the C20+C21 from php? 
or I need set a third cell for formula always?
Jan 18, 2009 at 10:28 PM
No, for a simple addition, you can also do:

$result = $objPHPExcel->getActiveSheet()->getCell('C20')->getValue() + $objPHPExcel->getActiveSheet()->getCell('C21')->getValue();


$nbr1 = $objPHPExcel->getActiveSheet()->getCell('C20')->getValue();
$nbr2 = $objPHPExcel->getActiveSheet()->getCell('C21')->getValue();
$result = $nbr1 + $nbr2;
Jan 18, 2009 at 11:15 PM

thanks a lots!!!

this work for me!

thanks again markbaker.