如何使用ADO.NET读取.XLSX(Excel 2007中)的文件?我发现"找不到可安装的ISAM" -error [英] How to read an .XLSX (Excel 2007) file using ADO.NET? I am finding "Could not find installable ISAM"-error

查看:194
本文介绍了如何使用ADO.NET读取.XLSX(Excel 2007中)的文件?我发现"找不到可安装的ISAM" -error的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 .NET 2.0 工作。所以,我不能使用的OpenXML。

这是我的源$ C ​​$ c和我已经安装了 AccessDatabaseEngine.exe

但仍然得到异常:

  

找不到可安装ISAM。

我也尝试扩展属性= Excel的8.0在连接字符串中

 静态无效的主要(字串[] args)
{
    数据集的数据集=新的DataSet();

    OleDbConnection的连接=新的OleDbConnection(@供应商= Microsoft.ACE.OLEDB.12.0;数据源= |资料目录| \ HSC.xlsx;扩展属性= Excel的12.0; HDR = YES;);
    OleDbDataAdapter的DataAdapter的=新OleDbDataAdapter的(SELECT * FROM [表Sheet1 $],连接);

    DataAdapter.Fill方法(数据集);
}
 

解决方案

据卡尔Prothman,这应该是

 扩展属性=创先争优12.0的Xml;
 

- <一个href="http://www.connectionstrings.com/excel-2007">http://www.connectionstrings.com/excel-2007

在更多详细信息:

  OleDbConnection的连接=新的OleDbConnection(@供应商= Microsoft.ACE.OLEDB.12.0;数据源= C:\\ \\文档Book2.xlsx;扩展属性='Excel的12.0 XML; HDR = YES;');
 

请注意单引号。

I need to work in .net 2.0. So I can't use OpenXML.

This is my source code and I have already Installed AccessDatabaseEngine.exe.

But still getting the exception:

"Could not find installable ISAM".

I have also tried "Extended Properties=Excel 8.0" in the connection string.

static void Main(string[] args)
{
    DataSet dataSet = new DataSet();

    OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|Data Directory|\HSC.xlsx;Extended Properties=Excel 12.0;HDR=YES;");           
    OleDbDataAdapter dataAdapter= new OleDbDataAdapter("select * from [Sheet1$]", connection);

    dataAdapter.Fill(dataSet);
}

解决方案

According to Carl Prothman, that should be

 Extended Properties="Excel 12.0 Xml;

-- http://www.connectionstrings.com/excel-2007

In more detail:

 OleDbConnection connection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Docs\\Book2.xlsx;Extended Properties='Excel 12.0 xml;HDR=YES;'");           

Note the single quotes.

这篇关于如何使用ADO.NET读取.XLSX(Excel 2007中)的文件?我发现&QUOT;找不到可安装的ISAM&QUOT; -error的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆