Home » excel » c# – Is it possible to access Excel file through ADO.NET that does NOT have a Header Row?

c# – Is it possible to access Excel file through ADO.NET that does NOT have a Header Row?

Posted by: admin May 14, 2020 Leave a comment

Questions:

I have a formated Excel file, over which I do not have control, and I need to read the information contained in it.

The problem with the file is that the first few rows contain formated information and I can not modify that file nor I can not ask for a format change.

Is it possible then, to read such a file through ADO.Net?

Thanks in advance,

How to&Answers:

I think this article explains how to do this pretty well:
http://support.microsoft.com/kb/316934

As for the lack of a header row…

With Excel workbooks, the first row in
a range is the header row (or field
names) by default. If the first range
does not contain headers, you can
specify HDR=NO in the extended
properties in your connection string.
If you specify HDR=NO in the
connection string, the Jet OLE DB
provider automatically names the
fields for you (F1 represents the
first field, F2 represents the second
field, and so on).