I switched from the Interop library to OpenXML because I need to read large Excel files. Before that I could use:
worksheet.UsedRange.Rows.Count
to get the number of rows with data on the sheet. I used this information to make progress. In OpenXML, I don't know how to get the same sheet information. Now I have this code:
using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(path, false)) { WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart; WorksheetPart worksheetPart = workbookPart.WorksheetParts.First(); SheetData sheetData = worksheetPart.Worksheet.Elements<SheetData>().First(); int row_count = 0, col_count;
source share