-
Notifications
You must be signed in to change notification settings - Fork 6
10 Read Table (using conventions)
René Pacios edited this page Jun 11, 2018
·
2 revisions
By default, library read table from first column and row used and assume that columns titles are in first row. For this sample we have next Excel table:
We define this VO class:
public class SimpleTable
{
public int Number { get; set; }
public string Name { get; set; }
public DateTime ADate { get; set; }
}
And we could read table
byte[] file = System.IO.File.ReadAllBytes([ExcelPath])
var wb = new ClosedXML.Excel.XLWorkbook(new MemoryStream(file));
IEnumerable<SimpleTable> data = wb.ReadTable<SimpleTable>(1); // indicate excel sheet
We have to indicate number of sheet where is the table. (First Excel document sheet is number 1)