problem with AdvancedValueBinder()

Topics: Developer Forum
Mar 3, 2011 at 3:40 PM
Edited Mar 3, 2011 at 3:52 PM


I have a program that writes a time on a cell and the following day a different time on the next cell.

i am using PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() );

On the first day, the time is saved OK.

on the second day (and from then on) the time is saved the right way for the current column, but the time on the previous on changes from 00:06:37 to 0.004595 (excel time?)

How can i avoid that?

i use 

$objPHPExcel->getActiveSheet()->setCellValue($this->columnName($current_month) . '1', '00:06:37');

to write the time


Mar 4, 2011 at 12:19 PM

I've tried to replicate this using the following code:

$fileType = 'Excel2007';
$fileName = 'testBinderTime.xlsx';

$objReader = PHPExcel_IOFactory::createReader($fileType);
$objPHPExcel = $objReader->load($fileName);

$sheet = $objPHPExcel->getActiveSheet();
PHPExcel_Cell::setValueBinder( new PHPExcel_Cell_AdvancedValueBinder() );

$timeNow = date('H:i:s');
$objPHPExcel->getActiveSheet()->setCellValue('A' . ($sheet->getHighestRow() + 1), $timeNow);

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $fileType);

but it is working exactly as I'd expect it to work.

I've tried this with both Excel5 and Excel2007, without seeing any of the previous values changing format in any way.

The only thing that I can think of is that you're reading the workbook with setReadDataOnly(true), which is telling PHPExcel not to read any format masking (which includes date masking).


Is it possible for you to create a code snippet that demonstrates this problem?

Mar 4, 2011 at 1:32 PM


you are right, i was using setReadDataOnly(true).

once removed, everything works fine.