Calculate Value for single column

Topics: Developer Forum, Project Management Forum, User Forum
Dec 15, 2011 at 9:46 PM
Edited Dec 15, 2011 at 10:13 PM

I am writing a timestamp in columns B and C from the database. I would like to apply a formula to column D that would do the following,

=(C14-B14)*1440

But I need the rows to increment? If there are 300 rows in the report I need this done 300 times for the values of B & C at each row...

I tried this but it did NOT work:

$objPHPExcel->getActiveSheet()->setCellValue('D'.$rowNumber,'=(C.$rowNumber-B.$rowNumber)*1440');

 

The purpose of this function is to give me the difference in time between timestamp B and timestamp C

Timestamps are in the following format: 2011-12-15 17:13:20

Coordinator
Dec 16, 2011 at 6:43 AM
Edited Dec 16, 2011 at 8:37 AM

Are you writing a string containing what looks like a time value to a human being (e.g. '2011-12-15 17:13:20') or an actual Excel timestamp?

If strings, then either convert them to an Excel timestamp value using the conversion functions in PHPExcel_Shared_Date, or use the Advanced Value binder to do this for you automatically.

And remember in your formula that PHP strings will only interpret variables correctly if enclosed in double quotes:

$objPHPExcel->getActiveSheet()->setCellValue('D'.$rowNumber,"=(C$rowNumber-B$rowNumber)*1440");

or

$objPHPExcel->getActiveSheet()->setCellValue('D'.$rowNumber,'=(C'.$rowNumber.'-B'.$rowNumber.')*1440');