I’m trying to read from excel file with oleDB provider using C#:
using (var fileConnection = new OleDbConnection(fileConnectionString))
{
var command = new OleDbCommand(@"Select SourceName, [ExternalID] FROM [page1$]", fileConnection);
fileConnection.Open();
var reader = command.ExecuteReader();
while (reader.Read())
{
yield return new Source
{
//some code
};
}
}
. The only problem is that some headers in excel file have a square bracket in their name like [ExternalID]. Is it possible to read them? How can I do it?
Thank you for your help!
Its simple. Create an excel doc which contains column called [ExternalId] and try get value. If you cant get that column value, use Adapter to get whole excel, and then you can find [ExternalID] column index. The index is what you need to get values.