Phpexcel - Library automatically converts the notation of the date when importing Excel spreadsheet, from dd/mm/yyyy switches to mm/dd/yyyy

Asked

Viewed 618 times

1

I’m going through a problem that’s already making me bald..

In a certain part of an application, I need to import the user’s data through an Excel spreadsheet, for this I am using the Phpexcel library.

However, when editing the information in Ms Excel, when importing, Phpexcel mysteriously changes the date notation.

Ex: I insert the following date in the spreadsheet, 10/07/2015 (dd/mm/yyyy), and import the date is 07/10/2015 (mm/dd/yyyy).

This problem happened in Libre Office Calc, but I formatted the date column for the dd/mm/yyyy notation, and the information is imported normally. Already in Ms Excel this does not solve.

I have created several filters with PHP to handle this type of "error" but it never works...

Has anyone been there? Any idea what to do?

Thank you very much!!

  • The date reported in Excel will be converted to a numerical sequence. For example: 01/09/2015 = 42248. I couldn’t understand why either, someone with more experience might help to understand this format. Well, my solution was to put the following line in the import file that calls Phpexcel. $val = date(’d/m/Y', Phpexcel_shared_date::Exceltophp( $Cell->getValue() ); See if this works for you.

  • The date must be exported (by PHP) in American format (Y-m-d). In excel, it usually understands and puts in the system format. But, if this doesn’t happen automatically, just format the cell

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.