-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Problem importing date #2315
Comments
Did you have a look at Formatting columns - Dates already? |
I'm talking about imports, not exports. |
Just use the function:
at least until it's fixed ;) |
@mariavilaro Do you need any more help with this ? Or is the solution provided by @clyall sufficient for your needs? |
No, I can't use that solution because I don't know which cells are dates in my excel file. The only "solution" that works for me right now is using PhpSpreadsheet directly to load the excel data. |
+1 for the same bug |
+1 for same bug. I don't know which cells are dates in my excel file, too. |
I have the same problem with the import process: all dates imported as numbers. I tried to extend my import class with StringValueBinder, implementing WithCustomValueBinder, but it seems that it doesn't work. Does anybody found a solution? I'm using:
|
have you tried \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject() ? |
Yes, now it works. Thanks |
+1 |
3 similar comments
+1 |
+1 |
+1 |
Will close this, as a more permanent solution will be part of the 4.x release |
Versions
Description
When I import a file with a date, it is imported as a number (47112.0) instead of a date (12/25/2028)
If I load a file with a date using PhpSpreadsheet, the date value is loaded ok:
Output:
But If I load the same file using an Importable, and in the BeforeSheet event I check the sheet values, the value is numeric:
Output:
Expected behavior:
I expect that the values that are formatted as dates in the excel file are correctly loaded as dates.
Actual behavior:
The values formatted as dates in the excel file are loaded as numbers.
Additional Information
I already checked this issue #1832 but the solution doesn't work for me, as I don't know which cells are dates in the excel file.
Also, seeing that PhpSpreadsheet returns the correct value, I think there's some problem somewhere in Laravel Excel.
The text was updated successfully, but these errors were encountered: