Format cell and open workbook in Excel

Topics: Developer Forum, User Forum
Feb 1, 2012 at 7:59 AM

Hi

 

Im formatting cell as time hh:mm:ss:

$workbook->excel->getActiveSheet()->getStyle('E3:E10')->getNumberFormat()->setFormatCode('hh:mm:ss');

 

If I open workbook in excel and check cell format I get that it is "Custom hh:mm:ss" as it must be. But format applies only after I focus in cell content and press enter.

How can I do that cell format is already applied if I open workbook in Excel?

 

Thank you in advance

I.

Coordinator
Feb 1, 2012 at 7:52 PM

It should already be correct. Can you create a "test case" worksheet demonstrating this problem and upload it for me to test.

Feb 2, 2012 at 9:18 AM
Edited Feb 2, 2012 at 9:21 AM

I create excel file as following:

$this->excel = new PHPExcel();
$this->excel->setActiveSheetIndex($idx)->setCellValueByColumnAndRow($i, $j, $value);
$this->excel->getActiveSheet()->getStyle('E3:E13')->getNumberFormat()->setFormatCode('[hh]:mm:ss');

http://arroba.ee/phpexcel/

Result xls file is attached. Also is attached screenshot how opened file looks like.
 Also is attached screenshot after hitting enter in cell - format applies as it should be.