Excel 2007 OLEDB 连接:文件包含超链接时出错

发布于 2024-09-15 04:03:50 字数 604 浏览 0 评论 0原文

在这里的每个人因重复而关闭这个问题之前,我应该说我已经看过其他问题,并尝试了答案但没有运气。

这是我正在使用的连接字符串,

strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FilePathBox.Text + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\"";

我对 2007 年的连接字符串进行了全面搜索,并且尝试了我见过的每一个连接字符串及其许多组合。但无论怎样,我都会收到一个异常,说外部表不是预期的格式

我安装了 Excel 2007,并尝试单独安装正确的驱动程序。

编辑

好吧,很奇怪的事情:它只发生在我尝试转换的文件上。我新建了一个 xlsx 文件,效果很好。恰好是这个特定的文件。

编辑2

我试图转换的文件中有电子邮件地址。输入电子邮件地址后,Excel 会自动将其设为超链接。这就是问题所在。如果我从文本中删除超链接,转换工作正常。如果文件包含超链接,连接时我必须做一些特别的事情吗?

Before everyone here closes this question for being a duplicate, I should say that I have looked at the other ones, and tried the answers with no luck.

Here's the connection string I'm using

strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + FilePathBox.Text + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\"";

I've searched high and low about the 2007 connection string and I've tried every single one I've seen and many combinations there of. But no matter what I get an exception saying External table is not in the expected format.

I have Excel 2007 installed and I tried installing the correct drivers seperately.

Edit

Ok so weird thing: It only happens with the file I'm trying to convert. I made a new xlsx file, and it worked fine. Just happens to be this particular file.

EDIT 2

The file I was trying to conver had email addresses in it. When the email address is typed in, excel automatically makes it a hyperlink. This is the problem. If I remove the hyperlink from the text, the conversion works fine. Is there something special i have to do when connecting if the file contains hyperlinks?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少女情怀诗 2024-09-22 04:03:50

这是适合我的 XLSX 文件:

strConn =
@"Provider=Microsoft.ACE.OLEDB.12.0;数据源=" + dataSource + ";扩展属性=\"EXCEL 12.0 XML;HDR=YES;IMEX=1\";持久安全信息=True;Jet OLEDB:数据库密码=admin”;

对于 xlsm,我使用:

strConn =
@"Provider=Microsoft.ACE.OLEDB.12.0;数据源=" + dataSource + ";扩展属性=\"EXCEL 12.0 Macro;HDR=YES;IMEX=1\";持久安全信息=True;Jet OLEDB:数据库密码=admin”;

Here is one that works for me for XLSX files:

strConn =
@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + dataSource + ";Extended Properties=\"EXCEL 12.0 XML;HDR=YES;IMEX=1\";Persist Security Info=True;Jet OLEDB:Database Password=admin";

For xlsm I use:

strConn =
@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + dataSource + ";Extended Properties=\"EXCEL 12.0 Macro;HDR=YES;IMEX=1\";Persist Security Info=True;Jet OLEDB:Database Password=admin";

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文