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

Inserting new row causes some address to return "XFD" instead. #3263

Closed
7 tasks
brianwong3 opened this issue Dec 29, 2022 · 3 comments · Fixed by #3264
Closed
7 tasks

Inserting new row causes some address to return "XFD" instead. #3263

brianwong3 opened this issue Dec 29, 2022 · 3 comments · Fixed by #3264

Comments

@brianwong3
Copy link

This is:

- [x ] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

Upon calling "insertNewRowBefore", the cell references should be updated correctly.

What is the current behavior?

Currently, after calling "insertNewRowBefore", any columns starting with "Y", and "Z" evaluates to "true" and PhpSpreadsheet sets the new column value to "AddressRange::MAX_COLUMN"

What features do you think are causing the issue

  • Reader
  • Writer
  • Styles
  • Data Validations
  • [x ] Formula Calculations
  • Charts
  • AutoFilter
  • Form Elements

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

So far only XLSX has been tested.

Which versions of PhpSpreadsheet and PHP are affected?

PhpSpreadsheet v1.26.0

After some digging, the issue seems to be from

$newColumn = ($newColumn > AddressRange::MAX_COLUMN) ? AddressRange::MAX_COLUMN : $newColumn;

@oleibman
Copy link
Collaborator

Confirmed, but this appears to be a bug in Php, not PhpSpreadsheet. I will attempt to open a ticket there. As far as I can tell, the code in question worked through PHP7.3, and became broken in PHP7.4.

@oleibman
Copy link
Collaborator

Actually, it is possible that PHP7.4 changed the way that column comparisons happened. I think we can probably fix this in PhpSpreadsheet after all.

@MarkBaker
Copy link
Member

MarkBaker commented Dec 29, 2022

Hmmmm, that looks like my bad; it was a bugfix that targeted ensuring that row/column ranges didn't fall outside the Excel max rows/columns, rather than cell ranges; but looks like I may have introduced a new bug for cell ranges in doing so
It should be fairly easy to fix by comparing the index value before converting to a string column name

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Dec 29, 2022
Fix PHPOffice#3263. Code was comparing column string to max column (XFD), but comparison was done by strings so that any column beginning with Y or Z would seem to exceed the max and would be handled incorrectly. Change to compare to maximum integer index of column (16384) instead.
oleibman added a commit that referenced this issue Jan 1, 2023
Fix #3263. Code was comparing column string to max column (XFD), but comparison was done by strings so that any column beginning with Y or Z would seem to exceed the max and would be handled incorrectly. Change to compare to maximum integer index of column (16384) instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants