Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

By using Maatwebsite/Laravel-Excel version 3.1 to import excel sheet, here I faced an issue date time column of the excel sheet returns unknown number. How to solve this? Example : Consider Cell value "29/07/1989" and returns as "32178" when import.

like image 256
Reno Anthus Avatar asked Mar 28 '19 04:03

Reno Anthus


1 Answers

The numbers come from excel itself, dates stored in excel as numeric values. http://www.cpearson.com/excel/datetime.htm

For Laravel framework 5.6 and maatwebsite/excel package version 3.1, to convert date from excel numbers to normal date format, this function PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($dateFromExcel) can be used. It accepts integer(excel date) and returns DateTime object.

More information can be found here https://github.com/Maatwebsite/Laravel-Excel/issues/1832

From this answer: https://stackoverflow.com/a/55139981/9133724

like image 194
Qraxin Avatar answered Sep 16 '22 11:09

Qraxin