打开与C#的Excel 2003电子表格。找不到可安装ISAM。例外 [英] Open an Excel 2003 spreadsheet with C#. Could not find installable ISAM. Exception

查看:281
本文介绍了打开与C#的Excel 2003电子表格。找不到可安装ISAM。例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从XLS提取数据,我也需要让用户可以更改文件它会的位置。所以一个OleDbConnection似乎是一个良好的开端,这是直到第一个合并的单元格

I need to pull data from an xls, I also need have the user be able to change the location of the file it will. So an OleDbConnection seemed like a good start, and it was until the first merged cell.

这适用于所有,但合并单元格:

This works for all but the merged cells:

OleDbCommand cmd = new OleDbCommand();
cmd.Connection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data 
Source=F:\test.xls;Extended Properties=Excel 8.0;");
cmd.CommandText = "SELECT * FROM [Sheet$]";
cmd.Connection.Open();



我发现,这应该允许访问合并单元格:

I found that this should allow access to the merged cells:

OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\test.xls;Extended Properties=Excel 8.0;HDR=Yes;IMEX=1;");



但后来我得到一个无法找到cmd.conn.open()安装的ISAM例外;

But then I get a Could not find installable ISAM exception on cmd.conn.open();

我跟这里的建议是:
HTTP ://support.microsoft.com/kb/209805

在这里:
http://stackoverflow.com/questions/512143/error-could-not-find-installable-isam

没有运气。

我愿意从XLS提取数据的其他方式。甚至如果有一个命令,我可以在XLS去除mirged细胞可能的工作运行。

I’m open to other ways of pulling data from the xls. Or even if there was a command I could run on the xls to remove the mirged cells that might work.

推荐答案

我认为这是只是因为你有附上扩展属性的报价,如果你有一个以上的

I think it's just because you have to enclose the Extended Properties in quotes if you have more than one

OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\test.xls;
Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';");



或者,如果单引号不工作(你的想法)

Or if single quotes don't work (you get the idea)

OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\test.xls;
Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1;"";");



当你的例子并没有表现出来,这个错误也可以通过在文件路径中有空格引起的。在这种情况下,你需要用引号括文件路径也是如此。

While your example doesn't show it, this error can also be caused by spaces in the file path. In which case you would need to wrap the file path in quotes as well.

OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=""F:\test.xls"";...

这篇关于打开与C#的Excel 2003电子表格。找不到可安装ISAM。例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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