xlsx icon indicating copy to clipboard operation
xlsx copied to clipboard

readRowsFromSheet does not handle case where row number is missing

Open mrog opened this issue 9 months ago • 0 comments

In lib.go, the function readRowsFromSheet assumes that the raw row always has a row number. However, the row number is optional according to ECMA-376 5th edition. See the definition of CT_ROW in part 1, appendix 2.

I receive spreadsheets where the row number is missing from the first row. This causes the first row of data to have an index of -1 instead of 0. Then the second row has an index of 1. When row 0 is requested using the library, a blank row is returned.

This could be fixed by adding a check here. For the first row, if rawrow.R is 0, then row.num should be 0.

The file spec isn't clear about how to handle subesquent rows without row numbers. I suppose the code could simply add 1 to the previous row number when rawrow.R is 0.

mrog avatar Jul 22 '25 20:07 mrog