Phpspreadsheet - Time cell retrieved as float

后端 未结 2 460
说谎
说谎 2021-01-21 08:47

I have an excel file which has a time input.

  Mar 01, 2018  | Thursday  | 8:00 AM | 5:00 PM
  Mar 02, 2018  | Friday    | 8:00 AM | 5:00 PM

B

2条回答
  •  醉话见心
    2021-01-21 09:08

    Formart the data before you read it.

    For example:

    cell data 2020/10/13 19:00:00

    Access directly will get 44117.791666667

    $sheet->toArray();
    

    Format before access will get 2020-10-13 19:00:00

    $row_num = $sheet->getHighestDataRow();
    $sheet->getStyle("H1:H$row_num")->applyFromArray(array("numberFormat"=>array("formatCode"=>'yyyy-mm-dd hh:mm:ss'))); // H is the datatime row
    $sheet->toArray();
    

提交回复
热议问题