I'm using this code to open an excel file and save it in a DataGridView:
string name = "Items";
string constr = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source=" + Dialog_Excel.FileName.ToString() + "; Extented Properties =\"Excel 8.0; HDR=Yes;\";";
OleDbConnection con = new OleDbConnection(constr);
OleDbDataAdapter sda = new OleDbDataAdapter("Select * From [" + name + "$]", con);
DataTable data = new DataTable();
sda.Fill(data);
grid_items.DataSource = data;
As explained on: This youtube link
But I get an ISAM error. Any suggestion?
try the following program
Since you have not replied to my comment above, I am posting a solution for both.
You are missing
'
inExtended Properties
For Excel 2003 try this (TRIED AND TESTED)
BTW, I stopped working with Jet longtime ago. I use ACE now.
For Excel 2007+
try this following snippet, its working fine.
I used the following code, it's working!