Skip to content

Conversation

oleibman
Copy link
Collaborator

My system short date format is set to yyyy-mm-dd. I used Excel to create a spreadsheet, and included some dates, specifying yyyy-mm-dd formatting. When I looked at the resulting spreadsheet, I was surprised to see that Excel had stored the style not as yyyy-mm-dd, but rather as builtin style 14 (system short date format). Apparently the fact that the Excel styling matched my system choice was sufficient for it to override my choice! This is an astonishingly user-hostile implementation. Even though there are formats which, by design, "respond to changes in regional date and time settings", and even though the format I selected was not among those, Excel decided it was appropriate to vary the display even when I said I wanted an unvarying format.

This PR adds a new method replaceBuiltinNumberFormat to undo the damage that Excel does in such a situation. It also adds an Excel Anomalies document to the formal documentation, just to make situations like this readily available to the community.

BTW, Excel's sabotage can be avoided by using a number format style like [Black]yyyy-mm-dd.

This is:

  • a bugfix
  • a new feature
  • refactoring
  • additional unit tests
  • a fix for a bug in Excel

Checklist:

oleibman added 3 commits July 10, 2025 17:54
My system short date format is set to `yyyy-mm-dd`.
I used Excel to create a spreadsheet, and included some dates, specifying `yyyy-mm-dd` formatting. When I looked at the resulting spreadsheet, I was surprised to see that Excel had stored the style not as `yyyy-mm-dd`, but rather as builtin style 14 (system short date format). Apparently the fact that the Excel styling matched my system choice was sufficient for it to override my choice! This is an astonishingly user-hostile implementation. Even though there are formats which, by design, "respond to changes in regional date and time settings", and even though the format I selected was not among those, Excel decided it was appropriate to vary the display even when I said I wanted an unvarying format.

This PR adds a new method `replaceBuiltinNumberFormat` to undo the damage that Excel does in such a situation. It also adds an `Excel Anomalies` document to the formal documentation, just to make situations like this readily available to the community.

BTW, Excel's sabotage can be avoided by using a number format style like `[Black]yyyy-mm-dd`.
@oleibman oleibman enabled auto-merge July 15, 2025 06:39
@oleibman oleibman added this pull request to the merge queue Jul 15, 2025
Merged via the queue into PHPOffice:master with commit 2d67646 Jul 15, 2025
13 of 14 checks passed
@oleibman oleibman deleted the builtinnumfmt branch July 15, 2025 07:05
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.

1 participant