Skip to content
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

Handle Explicit "Date" Type for Cell #2485

Merged
merged 2 commits into from
Jan 14, 2022
Merged

Conversation

oleibman
Copy link
Collaborator

@oleibman oleibman commented Jan 4, 2022

Fix #2373. Excel can handle DateTime/Date/Time as a string if the datatype of the cell is set to "d". The string is, apparently, supposed to follow the ISO8601 spec. Openpyxl can be configured to generate a file with such values, so I've added support and set up unit tests. Excel, naturally, converts such a string input into its numeric representation of the date/time stamp. So will PhpSpreadsheet, so a call to setValueExplicit specifying Date format will actually see the cell wind up with Numeric format - there is no way (and no reason) for the Date type to 'stick'.

This is:

- [x] a bugfix
- [ ] a new feature

Checklist:

Why this change is needed?

Fix PHPOffice#2373. Excel can handle DateTime/Date/Time as a string if the datatype of the cell is set to "d". The string is, apparently, supposed to follow the ISO8601 spec. Openpyxl can be configured to generate a file with such values, so I've added support and set up unit tests. Excel, naturally, converts such a string input into its numeric representation of the date/time stamp. So will PhpSpreadsheet, so a call to setValueExplicit specifying Date format will actually see the cell wind up with Numeric format - there is no way (and no reason) for the Date type to 'stick'.
@oleibman
Copy link
Collaborator Author

oleibman commented Jan 4, 2022

No plans to address Scrutinizer "complexity" problem. Added a new datatype that requires processing; some additional complexity is to be expected.

@oleibman oleibman merged commit 8ab8345 into PHPOffice:master Jan 14, 2022
@oleibman oleibman deleted the explicitdate branch February 6, 2022 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

PhpOffice\PhpSpreadsheet\Exception: Invalid datatype: d
1 participant