-
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
Wrong calculation of highest column with specified row #700
Comments
I think the error lies in public function getHighestColumn($row = null)
{
if ($row == null) {
$colRow = $this->getHighestRowAndColumn();
return $colRow['column'];
}
$columnList = [1];
// ...
return Coordinate::stringFromColumnIndex(max($columnList) + 1);
}
|
Same here except sometimes the max value is higher than 1. I sometimes just change an unrelated -lesser- column, hit save in Excel and the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
For future reference, the way I went around this problem is by checking the values for each column using some heuristics to detect when there was no more data. For example, if you detect 50 empty columns then most likely your data has already finished. This is definitely not perfect but for my very basic use will suffice. |
The wrong value is caused by two parts: \PhpOffice\PhpSpreadsheet\Collection\Cells::getHighestColumn()
\PhpOffice\PhpSpreadsheet\Reader\Xlsx::readColumnsAndRowsAttributes()
Commit as referenced by pull request #856 fixes both parts and is tested on a production website. On the production website, the produced XLSX files contain many blank pages when printed, which is due to the wrong +1 column count as described in issue #700. This commit fixes the printing issue with correct count value returned. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
- Add changelog entry for issue PHPOffice#700
- Add changelog entry for issue #700
* Fix wrong calculation of highest column issue PHPOffice#700 * Revert "Fix wrong calculation of highest column" This reverts commit ef39af1. * Revert "Revert "Fix wrong calculation of highest column"" This reverts commit d13493e. * Revert Xlsx reader * Fix indentation
- Add changelog entry for issue PHPOffice#700
I've noticed that getHighestRow() and getHighestColumn() are influenced by the active cell--as in the cell that you last clicked. I've had only 4 rows and 2 columns, but my active cell was like F18 because that was where I clicked before saving the file. The max values were F and 18 instead of B and 4. So, I've placed the cursor in A1 and saved the file. That fixed my problem, but I think the 2 methods should take into consideration only cell values and not the empty active cell. |
Consider using the |
Fixed by PR #944. |
This is:
What is the expected behavior?
When reading an empty spreadsheet file, the highest (data) column for a given row should be
A
ornull
.What is the current behavior?
When calling
\PhpOffice\PhpSpreadsheet\Collection\Cells::getHighestColumn()
with$row !== null
the method returns the column 1 to high.What are the steps to reproduce?
\PhpOffice\PhpSpreadsheet\Reader\Xlsx::load()
\PhpOffice\PhpSpreadsheet\Collection\Cells::getHighestColumn(1)
'B'
Which versions of PhpSpreadsheet and PHP are affected?
1.4
7.2
The text was updated successfully, but these errors were encountered: