Answer the question
In order to leave comments, you need to log in
How to write dates to .xlsx using PHPExcel?
Good afternoon. The code:
$my_date = date('d.m.Y', time()+60*20);
$objPHPExcel->getActiveSheet()->getStyle('D2')->getNumberFormat()->setFormatCode('DD.MM.YYYY');
$objPHPExcel->getActiveSheet()->SetCellValue('D1', $my_date);
Answer the question
In order to leave comments, you need to log in
$xls = PHPExcel_IOFactory::load("test.xlsx");
$xls->setActiveSheetIndex(0);
$sheet = $xls->getActiveSheet();
for($counter = 0; $counter < 10; $counter++)
{
$currentCellDate = date('d.m.Y', strtotime('+'.($counter).' day'));
echo $currentCellDate."\n";
$xls->getActiveSheet()->setCellValueByColumnAndRow(0, $counter + 1, $currentCellDate);
}
$objWriter = PHPExcel_IOFactory::createWriter($xls, 'Excel2007');
$objWriter->save("test.xlsx")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question