Importing from Excel - Header is not on row 1

家住魔仙堡 提交于 2019-12-07 18:50:17

问题


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]

回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/4761234/importing-from-excel-header-is-not-on-row-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!