I'm going through an excel with the library DocumentFormat.OpenXml
, and when I get the rows, I get rows in which the cells are empty; that is, I have an excel where you only have information in the first 10 rows, but you are extracting information from the first 140 rows.
using (SpreadsheetDocument spreadDoc = SpreadsheetDocument.Open(stream, true))
{
IEnumerable<Sheet> sheets = spreadDoc.WorkbookPart.Workbook.GetFirstChild<Sheets>().Elements<Sheet>();
string relationshipId = sheets.First().Id.Value;
WorksheetPart worksheetPart = (WorksheetPart)spreadDoc.WorkbookPart.GetPartById(relationshipId);
Worksheet workSheet = worksheetPart.Worksheet;
SheetData underscoreSheetData = workSheet.GetFirstChild<SheetData>();
IEnumerable<Row> underscoreRows = underscoreSheetData.Elements<Row>();
var numRows=underscoreRows.Count();
}
How can I get only the rows in which there is information, in this case the first 10 rows.
Thanks