Quantcast
Channel: Excel Data Reader - Read Excel files in .NET
Viewing all articles
Browse latest Browse all 448

Commented Unassigned: Can't reference column by name? (non-DataTable) [13568]

$
0
0
How do I reference a field by it's (first) column name when not using a DataTable?

while (excelReader.Read())
{
var branch = excelReader["Branch"].ToString(); // <-- I get a __NotSupportedException__

Also, it seems the "IsFirstRowAsColumnNames" property is ignored if you're enumerating the reader? I checked a value by index and it was the header row.
Comments: ** Comment from web user: jonkey86 **

I have a similar issue in which if my column header has a trailing space, the ExcelDataReader will not be able to parse the column

I can usually do this, row["ColumnName"] but if when it has a trailing space, I can't event do this row["ColumnName "] as I get the same exception.

My only choice is to either remove the trailing space from the spreadsheet, or reference the column by index.

Anyone experience something similar?


Viewing all articles
Browse latest Browse all 448

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>