Thursday, September 1, 2016

ClosedXML: parse excel table based on column names instead of indexes

ClosedXML is a library which provides object oriented way to manipulate Excel 2007/2010 files. I used it in one of the projects to parse table of data from spreadsheet. However, I discovered that there was no way (maybe there is now) to parse the table using the column names. For a while I used column indexes but when the table comes in with rearranged columns the mapping breaks. So I came up with the following solution.