![](/img/trans.png)
[英]“Could Not find Installable ISAM” C# Exception after reading xls file
[英]“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()); }
這是我的連接字符串:
字符串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;"
字符串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;";
使用連接字符串1讀取xls文件時出錯
“找不到可安裝的isam”
但是使用連接字符串2讀取xlsx文件;它工作正常:沒有錯誤!
錯誤是因為連接
for .xls嘗試此連接字符串:
StrConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + srcFile + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\";";
並為.xlsx嘗試此連接字符串:
StrConn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + srcFile + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";";
您的第一個連接字符串包括Excel 8.0 Xml;
哪個不行。 使用Excel 8.0;
代替。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.