-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Invalid date calendar format detection while loading several spreadsheets #1036
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Reopening, to be closed properly by a PR which will fix the problem. |
oleibman
added a commit
to oleibman/PhpSpreadsheet
that referenced
this issue
Jun 23, 2024
This change is extracted from PR PHPOffice#2787 by @MarkBaker. That change mostly deals with array functions, and that part will be superseded by PR PHPOffice#3962. However, this part of 2787 is not included in 3962. Fix PHPOffice#1036 (closed as stale in 2019 and just reopened). Excel spreadsheets can have either of 2 base dates, 1900 or 1904, and the numeric value of any date cells will vary depending on which base date is in use. PhpSpreadsheet has, till now, handled that as a static property of Shared/Date. This does not work well if two spreadsheets with different base dates are open simultaneously. The code is changed to store the base date as a property of the spreadsheet when an Xls/Xlsx spreadsheet is loaded, and use that property when saving an Xls/Xlsx spreadsheet. Any call to `getCalculatedValue` or `getFormattedValue` will temporarily set the Shared/Date value to that of the spreadsheet, and restore it at completion. In order to avoid a BC break, the Xls and Xlsx readers will continue to populate the Shared/Date value as before.
11 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is:
I came across this issue while I was writing tests with loading several spreadsheets and some datetime values was clearly invalid.
What is the expected behavior?
Loading numerious xlsx files should not share global state. Problematic is \PhpOffice\PhpSpreadsheet\Shared\Date::$excelCalendar
Problematic code https://github.com/PHPOffice/PhpSpreadsheet/blob/master/src/PhpSpreadsheet/Reader/Xlsx.php#L662
What is the current behavior?
\PhpOffice\PhpSpreadsheet\Shared\Date::$excelCalendar configuration can be shared across multiple spreadsheets
What are the steps to reproduce?
working example with testing data can be found on gist
Which versions of PhpSpreadsheet and PHP are affected?
1.7.0
but referenced code is 3-4 years old so it could be many versions
The text was updated successfully, but these errors were encountered: