开发者

Importing from Excel - Header is not on row 1

开发者 https://www.devze.com 2023-02-05 19:37 出处:网络
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 connectio

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]


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消