简体   繁体   中英

How can I read only first row from an Excel file with OleDbDataAdapter?

Can anybody help me? How can I read only first row from an Excel file with OleDbDataAdapter?

I know how I can read all data from any spread sheet:

var dataAdapter = new OleDbDataAdapter("SELECT * FROM [" + sheetName + "$]", oledbConnection);

But I don't know how can I do this for one row.

select top 1 * from ... 

你可以参考一个范围:

var dataAdapter = new OleDbDataAdapter("SELECT * FROM [" + sheetName + "$A1:C2]", oledbConnection);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM