Importing from Excel - Header is not on row 1

2019-05-25 14:07发布

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]

2条回答
我想做一个坏孩纸
2楼-- · 2019-05-25 14:10

To my knowledge, neither the HDR parameter or the schema.ini file allow anything but the first row to be the header row.

http://msdn.microsoft.com/en-us/library/ms709353%28v=vs.85%29.aspx

查看更多
Juvenile、少年°
3楼-- · 2019-05-25 14:29

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.

查看更多
登录 后发表回答