Formatting issue - what am I missing?

Topics: User Forum
Mar 12, 2014 at 2:33 PM
Edited Mar 12, 2014 at 2:35 PM
When I call setFormatCode() starting from a Sheet object, the formatting works as expected. However, when I call it starting from a Cell object, the format code is applied to every cell.
$sheet = $objPHPExcel->setActiveSheetIndex(0);
$cell = $sheet->getCellByColumnAndRow($start_col + $c, $start_row + $r);
$ts = date_ts($value); // converts text date such as '2014-03-01' to unix timestamp
$cell->setValue(PHPExcel_Shared_Date::PHPToExcel($ts));
// this does not work...
//$cell->getStyle()->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD);

// this works...
$sheet->getStyleByColumnAndRow($start_col + $c, $start_row + $r)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD);