Connecting C# 4 to excel 12.0 library(excel 2007)
Hi,
I am trying to connect to excel 12.0 from c# 4.0. I use the following code.
Code:
string excelConnection = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" + txtFile.Text +
"; Extended Properties=Excel 12.0; HDR=yes;IMEX=1;ImportMixedTypes=Text";
DataTable table = new DataTable();
using (OleDbConnection oledbConn = new OleDbConnection(excelConnection)) {
oledbConn.Open();
using (OleDbCommand command = new OleDbCommand("Select * from [Sheet1$]", oledbConn)) {
OleDbDataReader reader = command.ExecuteReader();
table.Load(reader);
}
}
It is compiling good. But in runtime, it produces the error - OleDbException unhandled - Could not find installable ISAM. Please help.