I have been using OleDbConnection
to read an Excel files from my C# code.
Everything work great when the file has a top header row and the data following it down.
The following connection string is used:
var query = "SELECT [Col1],[Col2],[Col3] FROM [Sheet1$]";
Now I need to process an Excel file that has an obligatory content from the first down to the 15th row. The 15th row is a header row and the rest is the data for the rows.
How can I read such a file?
To read from 15th row, modify your query to use table name as FROM [Sheet1$A15:ZZ]
-
var query = string.Format("select [Col1],[Col2],[Col3] from [{0}${1}]", "Sheet1","A15:ZZ");
A15 represents header row.
Make sure that you have set "HDR=YES"
in your connection string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.