I am new to epplus, and i\'m trying to read some values from an excel table.
This is what I have so far:
var fileInfo = new FileInfo(filename);
using(var e
You can access the .Worksheet
property of a table and index its cells. I wrote an extension method for this purpose, which generates a series of dictionaries mapping column name to cell value:
public static IEnumerable> GetRows(this ExcelTable table)
{
var addr = table.Address;
var cells = table.WorkSheet.Cells;
var firstCol = addr.Start.Column;
var firstRow = addr.Start.Row;
if (table.ShowHeader)
firstRow++;
var lastRow = addr.End.Row;
for (int r = firstRow; r <= lastRow; r++)
{
yield return Enumerable.Range(0, table.Columns.Count)
.ToDictionary(x => table.Columns[x].Name, x => cells[r, firstCol + x].Value);
}
}