简体   繁体   English

“找不到可安装的ISAM” - “。xlsx”读取没有错误但是读取“xls”文件在Windows 7 32bit上获取该错误

[英]“Could not find installable ISAM” - “.xlsx” reading no errors but reading “xls” file Get that error on windows 7 32bit

 OleDbConnection excelConnection=null;
            try
            {
                if (Path.GetExtension(excelFileName).Equals(".xls"))
                {
                    string conStr = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + excelFileName + ";Extended Properties=" + "\"Excel 8.0 Xml;HDR=YES;IMEX=1;\"";
                    excelConnection = new OleDbConnection(conStr);
                }
                else
                {
                    string conStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + excelFileName + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1;\";";
                    excelConnection = new OleDbConnection(conStr);

                }
                excelConnection.Open(); ***// this statement get the error!!!***
            }
            catch (Exception ex) { MessageBox.Show(ex.ToString()); }

This is my connection strings: 这是我的连接字符串:

string 1. 字符串1。

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\~Projects IW\Desktop APPS\Maga\Book1.xls;Extended Properties="Excel 8.0 Xml;HDR=YES;IMEX=1;"

string 2. 字符串2。

Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\~Projects IW\Desktop APPS\Maga\Book1.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES;IMEX=1;";

When reading xls file using connection string 1 get error 使用连接字符串1读取xls文件时出错

"could not find installable isam" “找不到可安装的isam”

But reading xlsx file using connection string 2 ;it is works fine: NO Errors! 但是使用连接字符串2读取xlsx文件;它工作正常:没有错误!

Error is because of connection 错误是因为连接

for .xls try this connection string: for .xls尝试此连接字符串:

  StrConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + srcFile + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\";"; 

and for .xlsx try this connection string: 并为.xlsx尝试此连接字符串:

StrConn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + srcFile + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";";

Your first connection string includes Excel 8.0 Xml; 您的第一个连接字符串包括Excel 8.0 Xml; which will not work. 哪个不行。 Use Excel 8.0; 使用Excel 8.0; instead. 代替。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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