PHPExcel日期导出格式

时间:2016-11-02 08:45:01

标签: phpexcel

需要将一些日期从MySql导出到Excel, 来源日期格式:2016-11-02, 目标日期格式:02.11.2016,所以 尝试:

PM> Install-Package    WindowsAzure.Storage -Version [your_version_number]-preview -Pre

然后,阅读单元格' 02.11.2016 - 带引号的日期

1 个答案:

答案 0 :(得分:0)

        if (empty($meter['test_date'])) {
            $objDoc->getActiveSheet()->setCellValue("T{$pRow}", '');
        } else {
            \PHPExcel_Cell::setValueBinder(new \PHPExcel_Cell_AdvancedValueBinder());
            $objDoc->getActiveSheet()->setCellValue("T{$pRow}", $meter['test_date']);
            $objDoc->getActiveSheet()->getStyle("T{$pRow}")->getNumberFormat()->setFormatCode("dd.mm.yyyy");
        }
        if (empty($meter['filling_date'])) {
            $objDoc->getActiveSheet()->setCellValue("U{$pRow}", '');
        } else {
            \PHPExcel_Cell::setValueBinder(new \PHPExcel_Cell_AdvancedValueBinder());
            $objDoc->getActiveSheet()->setCellValue("U{$pRow}", $meter['filling_date']);
            $objDoc->getActiveSheet()->getStyle("U{$pRow}")->getNumberFormat()->setFormatCode("dd.mm.yyyy");
        }
        $objDoc->getActiveSheet()

谢谢Mark,我明白了