user968441
user968441

Reputation: 1471

Error connecting to excel

I need to programmatically read Microsoft Excel file from a specific path. The following code results in an error message I have never seen before

string sConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Server.MapPath("Book1.xls") + ";" + "Extended Properties=Excel 12.0 Xml;HDR=Yes"; 
        OleDbConnection con = new OleDbConnection(sConnectionString);
        con.Open();

While opening the connection, the following error message is shown:

Could not find installable ISAM.

Does anybody have a solution related to this error? I would appreciate your help in this.

Upvotes: 0

Views: 106

Answers (1)

pascalhein
pascalhein

Reputation: 5846

According to this question, you have to enclose the properties in quotes and make sure the path doesn't contain spaces.

Change your code to

string sConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Server.MapPath("Book1.xls") + ";" + "Extended Properties='Excel 12.0 Xml;HDR=Yes'"; 

Upvotes: 3

Related Questions