protected void ReadRows(WorksheetPart worksheetPart, int startRow, int endRow)
{
OpenXmlReader reader = OpenXmlReader.Create(worksheetPart);
int count = 0;
int rowNum = 0;
while (reader.Read())
{
if (reader.ElementType == typeof(Row))
{
do
{
if (reader.HasAttributes)
rowNum = Convert.ToInt32(reader.Attributes.First(a => a.LocalName == "r").Value);
if (endRow == 0)
{
if (rowNum >= startRow)
{
Row row = (Row)reader.LoadCurrentElement();
//this.errorMessages = this.errorMessages.Union(Validate(RowToList(row), Convert.ToInt32(row.RowIndex.ToString()))).ToList();
this.DataTuples.Add(ReadRow(RowToList(row), Convert.ToInt32(row.RowIndex.ToString())));
count++;
}
}
else
{
if (rowNum >= startRow && rowNum <= endRow)
{
Row row = (Row)reader.LoadCurrentElement();
if (!IsEmpty(row))
{
this.DataTuples.Add(ReadRow(RowToList(row), Convert.ToInt32(row.RowIndex.ToString())));
}
//this.errorMessages = this.errorMessages.Union(Validate(RowToList(row), Convert.ToInt32(row.RowIndex.ToString()))).ToList();
count++;
}
}
} while (reader.ReadNextSibling()); // Skip to the next row
break;
}
}
}