I have attached a very simple excel file. When I read it with WB = Workbook.Load(io) the wrong number of rows are returned. This document contains 32 rows but your component, on the Rows property, returns 28. Now, there are 5 blank rows in the document which is probably the cause for this and you could think that these blank rows have been removed in Rows but there are blank rows in it so there is no way for me to read the last 4 rows.
I have 6 rows with records in the spreadsheet, however this syntax :
int numRows = worksheet.Rows[((ICollection<WorksheetRow>)worksheet.Rows).Count - 1].Index + 1;
is returning the record count as 5. What could be the possible reason?
Hello Henrik,
I am glad to hear this. Thank you.
Thank you - it works.
The blank cells in your Worksheet have formatting applied, affecting the overall row count, which makes sense because essentially were "accessed" as our docs mention. I performed a "Clear All" (Home > Editing > Clear) each cell and now you can get an exact row count and use a foreach loop to iterate through your worksheet rows to return all of them if needed. I attached my sample that I've been working on with your included excel file that demonstrates this. The sample also includes code that skips over the empty rows and only returns the values that are found.
Please let me know if you have any questions regarding this matter.
This is not the case. 28 rows are found but some are empty. Please test with the file supplied. I am using 14.1.