Importing from Excel - Header is not on row 1

novacara picture novacara · Jan 21, 2011 · Viewed 8.1k times · Source

Is there some simple way I am missing to import an Excel worksheet into a datatable using an OleDBConnection and change what row the header is located on? I have HDR=YES in my connection string and that works great when header is on row 1 but the header is actually going to need to be on row 3. I am using the following CommandText:

SELECT [headercol1name], [headercol2name], [headercol3name] FROM [sheetname]

Answer

Fionnuala picture Fionnuala · Jan 21, 2011

You can specify a range: How can I programmatically import Excel data into an Access table?

"SELECT * FROM [Sheet1$A3:G65536]" will only return records for used range, though I did not test very carefully.