-
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
Removing last row incorrect behavior #1364
Comments
5 tasks
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
PowerKiKi
pushed a commit
that referenced
this issue
Apr 26, 2020
`$highestRow = $this->getHighestDataRow();` was calculated after `$this->getCellCollection()->removeRow($pRow + $r);` - this is the root reason for incorrect rows removal because removing last row will change '$this->getHighestDataRow()' value, but removing row from the middle will not change it. So, removing last row causes incorrect `$highestRow` value that is used for wiping out empty rows from the bottom of the table: ```php for ($r = 0; $r < $pNumRows; ++$r) { $this->getCellCollection()->removeRow($highestRow); --$highestRow; } ``` To prevent this incorrect behavior I've moved highest row calculation before row removal. But this still doesn't solve another problem when trying remove non existing rows: in this case the code above will remove `$pNumRows` rows from below of the table, e.g. if `$highestRow=4` and `$pNumRows=6`, than rows 4, 3, 2, 1, 0, -1 will be deleted. Obviously, this is not good, that is why I've added `$removedRowsCounter` to fix this issue. And finally, moved Exception to early if statement to get away from unnecessary 'if-else'. Fixes #1364 Closes #1365
Fixed by PR #1365. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is:
What is the expected behavior?
What is the current behavior?
What are the steps to reproduce?
expected result is:
actual result is:
Which versions of PhpSpreadsheet and PHP are affected?
PhpSpreadsheet v1.10.1
PHP v7.4.2
The text was updated successfully, but these errors were encountered: