Bug 149856 - XLSX: the "highest row with data" marker will go to 1048576 when deleting any row within rows with data
Summary: XLSX: the "highest row with data" marker will go to 1048576 when deleting any...
Status: UNCONFIRMED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.3.4.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-05 04:30 UTC by Richard
Modified: 2022-07-06 05:34 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Just a simple XLSX created with MS Excel 2016 (8.23 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2022-07-06 05:34 UTC, Mike Kaganski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Richard 2022-07-05 04:30:11 UTC
Description:
Assume I have an Excel file (XLSX) with a data sheet containing several rows with data only (e.g. 10 rows), when deleting one of these rows with data and save, then open the Excel file with MS Excel or PHPSpreadsheet library, using Excel hot key to go to the highest row or using the $sheet->getHighestRow() goes to the 1048576th row respectively BUT NOT the 9th row. This will cause some problem when processing the Excel with some software library, e.g. PHPSpreadsheet

Steps to Reproduce:
1. open an Excel XLSX file with some rows with data
2. delete one of the data rows and save
3. open the resulting file with MS Excel or PHPSpreadsheet PHP programming library
4. press hotkey ([command]-[down arrow] x 2 times) for MS Excel or call $sheet->getHighestRow() when opening the Excel sheet using PHPSpreadsheet

Actual Results:
1. in MS Excel, pressing [command]-[down arrow] x 2 times will go to the 1048576th row
2. the $sheet->getHighestRow() returns 1048576

Expected Results:
1. in MS Excel, pressing [command]-[down arrow] x 2 times should go to the last row with data
2. should return the last row with data


Reproducible: Always


User Profile Reset: No


OpenGL enabled: Yes

Additional Info:
Version: 7.3.4.2 / LibreOffice Community
Build ID: 728fec16bd5f605073805c3c9e7c4212a0120dc5
CPU threads: 8; OS: Mac OS X 12.3; UI render: default; VCL: osx
Locale: en-HK (en_HK.UTF-8); UI: en-US
Calc: threaded
Comment 1 Mike Kaganski 2022-07-05 05:17:32 UTC
(In reply to Richard from comment #0)
> Expected Results:
> 1. in MS Excel, pressing [command]-[down arrow] x 2 times should go to the
> last row with data

No. The first press is expected to bring you to the last row of the current block; the second one should bring you to the end of the next block - or to the last physical spreadsheet row (1048576) if there's no blocks below. The behavior you describe is expected.

> 2. should return the last row with data

No. getHighestRow is not related to "rows with data" - unlike getHighestDataRow. See e.g. https://github.com/PHPOffice/PhpSpreadsheet/issues/2051 (which is basically the same issue).

Deleting rows from a file created in Excel must append new rows to the bottom; the default row heights differ between Excel and Calc -> the appended rows are narrower than the rest, and that *formatting* is reflected in the markup (and is detected by PHPSpreadsheet, and reflected by getHighestRow).

Eike: can we read the default row height from the file, or maybe clone formatting from the row above when appending new rows?
Comment 2 Eike Rathke 2022-07-05 20:52:46 UTC
I think the default row height should simply be set when reading such file if it is available from there (or maybe differs by generator application, but going down that route is also doomed to fail).
Comment 3 Mike Kaganski 2022-07-06 05:34:52 UTC
Created attachment 181131 [details]
Just a simple XLSX created with MS Excel 2016

(In reply to Eike Rathke from comment #2)
<sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/> is present in the attached sample. So this could be turned into "defaultRowHeight attribute of sheetFormatPr is not read / not taken into account when adding rows after row removal".