Excel Problem (Template Sheet)

Topics: Developer Forum
Jan 3, 2014 at 9:24 PM
Edited Jan 3, 2014 at 11:37 PM
Hi

well...

I have a template with 3 coluns, as follow:

Colunn A = Enter hour format( hh:mm:ss)
Colunn B = Enter hour format (hh:mm:ss)
colunn C = Automatic calculation of time.


When i fill manually, the sheet adjust automatically the cell.
Example:
When i write :

Colunn A = 00:18
Automatically the sheet adjust to 0:18.

When i write:
Colunn A = 08:17
Automatically the sheet adjust to 8:17

...


So, when i do it in PHPExcel, ... the cell dosen't adjust automatically
Example?
I write in PHPExce and save the sheet, the cells fit by program keep with the same value:
Example:
Colunn A = 00:18
Keep in 00:18



The problem is:

If i write
Colunn A : 19:57
Colunn B: 3:44

(Diferente between 2 hours)... This dosent work.


Help me;;;


I NEED THE PHPEXCEL ADJUST AS MY TEMPLATE!!



This is generating errors.
Jan 6, 2014 at 12:51 PM
It is necessary to convert your string ' h:m:s' in Excel time.
'Brutal' example:
$hours=13; $minutes=23; $seconds=0;// 13:23:00
$excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400;
$F->setCellValue('F3', $excelTime);
$hours=14; $minutes=53; $seconds=0;// 14:53:00
$excelTime = (($hours * 3600) + ($minutes * 60) + $seconds) / 86400;
$F->setCellValue('F4', $excelTime);
$F->setCellValue('F5', '=F4-F3');//display 01:30:00
//without the style, displaying as numbers like 0.5576389, 0.6201389, 0.0.625
$F->getStyle('F3:F5')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_TIME6);