简体   繁体   中英

“Could not find installable ISAM” error when trying to parse an excel spreadsheet

I am posting back a xls file and getting the error "Could not find installable ISAM" when filling the adapter. I have office 2007 32 bit , running xp 64bit

UPDATE changed connection string to 12.0 to 4.0 --same issue

  private string convertFileToPSV(HttpPostedFileBase file) {

        var connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                               "Source="+ fileName +";" +
                               "Extended Properties=\"Excel 8.0;HDR=YES;\"";

        var adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1]", connectionString);
        var dt = new DataTable();

        adapter.Fill(dt);

        string psvSting = "";

        for (int i = 0; i < dt.Rows.Count; i++) {
            for (int j = 0; j < dt.Columns.Count; j++) {
                psvSting += "\"" + dt.Rows[i][j].ToString() + "\"|";
            }
        }

I think my question can help you. It just need two ; at the end.

var connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                               "Source="+ fileName +";" +
                               "Extended Properties='Excel 8.0;HDR=YES;';";

As ron Said the DB driver you have selected is the access 2010 driver. If the machine you are running this on doesn't have access 2010... it won't work. as ron suggests you can download the driver here

Alternatively you may try Provider=Microsoft.Jet.OLEDB.4.0 as this comes with XP and Vista, If you are using windows 7 however you must use the download.

The excel version should also match which excel you are using:

Excel 2003 Excel 8.0

Excel 2007/2010 Excel 12.0

In Summary your connection string should read

var connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + 
                           "Source="+ fileName +";" + 
                           "Extended Properties=\"Excel 12.0;HDR=YES;\""; 

The Jet driver is only x86. If you try to run it on a x64 OS it won't work. Make sure that you target explicitly x86 in the properties of your .NET project to ensure that it loads the x86 unmanaged version of the driver.

Try using " Data Source= " in place of " Source= ".

var connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
                       "Data Source="+ fileName +";" +
                       "Extended Properties=\"Excel 8.0;HDR=YES;\"";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM