By data type
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
if($field[3] == 'int'){ $sheet->setCellValue($coordinate, $value); }elseif($field[3] == 'date'){ $sheet->setCellValue($coordinate, $value); $sheet->getStyle($coordinate) ->getNumberFormat() ->setFormatCode( \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME ); }else{ $sheet->setCellValueExplicit( $coordinate, $value, \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING ); } |
https://phpspreadsheet.readthedocs.io/en/latest/topics/accessing-cells/