I'm using the code below to access an Excel Sheet, but the adapter.Fill always throws an exception that the sheet could not be found.
string connectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\ImportSheet.xlsx;Extended Properties=""Excel 8.0;HDR=No;IMEX=1"";";
var adapter = new OleDbDataAdapter("SELECT * FROM [SheetName]", connectionString);
var ds = new DataSet();
adapter.Fill(ds, "anyNameHere");
I verified the path for the file and the sheetname, but i'm not sure why i keep getting this error. Would appreciate your help.
[SheetName$]
add the dollar sign after the name of the sheet – Steve
Try "SELECT * FROM [SheetName$]"
– danijepg