With EPPlus and OpenXML does anyone know the syntax on how to count the rows?
Say my worksheet is called \"worksheet\"
int numberRows = worksheet.rows.
Thanks for that tip Quppa. I used it in my bid to populate a DataTable from a Workbook Spreadsheet as below:
///
/// Converts a Worksheet to a DataTable
///
///
///
private static DataTable WorksheetToDataTable(ExcelWorksheet worksheet)
{
// Vars
var dt = new DataTable();
var rowCnt = worksheet.Dimension.End.Row;
var colCnt = worksheet.Dimension.End.Column + 1;
// Loop through Columns
for (var c = 1; c < colCnt; c++ )
{
// Add Column
dt.Columns.Add(new DataColumn());
// Loop through Rows
for(var r = 1; r < rowCnt; r++ )
{
// Add Row
if (dt.Rows.Count < (rowCnt-1)) dt.Rows.Add(dt.NewRow());
// Populate Row
dt.Rows[r - 1][c - 1] = worksheet.Cells[r, c];
}
}
// Return
return dt;
}