Question

Is there any way to select the Excel sheet used range via OLEDB Command object?

Because I have an Excel file that has 400 rows, but when I delete 200 rows and try to select the sheet again, it's selecting up to 400 rows again instead of selecting the 200 rows. This is the code which I've written to select the sheet:

oledbConn = new OleDbConnection(connectionString);
oledbCmd = new OleDbCommand("select * from [Sheet1$]", oledbConn);
oledbConn.Open();
oledbDr = oledbCmd.ExecuteReader();
    while(oledbDr.Read())
    {
}

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top