PHPExcel Calculation Example

Data/Time Formulae

TIME

getActiveSheet(); // Add some data $testDates = array( array(3,15), array(13,15), array(15,15,15), array(3,15,30), array(15,15,15), array(5), array(9,15,0), array(9,15,-1), array(13,-14,-15), array(0,0,-1) ); $testDateCount = count($testDates); $worksheet->fromArray($testDates,NULL,'A1',true); for ($row = 1; $row <= $testDateCount; ++$row) { $worksheet->setCellValue('D'.$row, '=TIME(A'.$row.',B'.$row.',C'.$row.')'); $worksheet->setCellValue('E'.$row, '=D'.$row); } $worksheet->getStyle('E1:E'.$testDateCount) ->getNumberFormat() ->setFormatCode('hh:mm:ss'); echo '
'; // Test the formulae ?> '; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } ?>
Date Value Formula Excel TimeStamp Formatted TimeStamp
Hour Minute Second
' , $worksheet->getCell('A'.$row)->getFormattedValue() , '' , $worksheet->getCell('B'.$row)->getFormattedValue() , '' , $worksheet->getCell('C'.$row)->getFormattedValue() , '' , $worksheet->getCell('D'.$row)->getValue() , '' , $worksheet->getCell('D'.$row)->getFormattedValue() , '' , $worksheet->getCell('E'.$row)->getFormattedValue() , '