0

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.

svick
  • 236,525
  • 50
  • 385
  • 514
user968441
  • 1,471
  • 9
  • 22
  • 48

1 Answers1

3

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'"; 
Community
  • 1
  • 1
pascalhein
  • 5,700
  • 4
  • 31
  • 44