Skip to content

Consistent Usage of Column and Row Limits#4820

Open
oleibman wants to merge 3 commits intoPHPOffice:masterfrom
oleibman:literals
Open

Consistent Usage of Column and Row Limits#4820
oleibman wants to merge 3 commits intoPHPOffice:masterfrom
oleibman:literals

Conversation

@oleibman
Copy link
Collaborator

@oleibman oleibman commented Mar 4, 2026

We have identical constants defined in several places, and use literals in others. We aren't consistent in checking limits. This PR makes the use of the constants in Cell/AddressRange the "official" source, deprecates all other constants, and substitutes the constants wherever literals are used. A number of different edge case tests are added.

During testing, I discovered that columnIndexFromString correctly throws an exception for 4-character string, but allows XFE through ZZZ, all of which are also invalid. There are similar inconsistencies with related routines, and this PR attempts to make them operate consistently. One suprise is that throwing for row=0 causes serious regression problems, so it continues to be permitted (but the high row limit is enforced).

Further, Reference Helper sometimes dips into negative numbers, resulting in totally unexpected results (-1 affects column Z, -2 column Y, etc.). It is changed to ignore rows and columns outside the limits.

This is:

  • a bugfix
  • a new feature
  • refactoring
  • additional unit tests

Checklist:

oleibman added 3 commits March 3, 2026 19:04
We have identical constants defined in several places, and use literals in others. We aren't consistent in checking limits. This PR makes the use of the constants in Cell/AddressRange the "official" source, deprecates all other constants, and substitutes the constants wherever literals are used. A number of different edge case tests are added.

During testing, I discovered that `columnIndexFromString` correctly throws an exception for 4-character string, but allows `XFE` through `ZZZ`, all of which are also invalid. There are similar inconsistencies with related routines, and this PR attempts to make them operate consistently. One suprise is that throwing for `row=0` causes serious regression problems, so it continues to be permitted (but the high row limit is enforced).

Further, Reference Helper sometimes dips into negative numbers, resulting in totally unexpected results (-1 affects column Z, -2 column Y, etc.). It is changed to ignore rows and columns outside the limits.
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