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

Can someone help me? How can I read only the first row from an Excel file using OleDbDataAdapter?

I know how I can read all the data from any distribution sheet:

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

But I do not know how to do this for one line.

+3
source share
2 answers
select top 1 * from ... 
+7
source

You can refer to the range:

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

Source: https://habr.com/ru/post/1749560/


All Articles