Excel 2007 OLEDB 连接:文件包含超链接时出错
在这里的每个人因重复而关闭这个问题之前,我应该说我已经看过其他问题,并尝试了答案但没有运气。
这是我正在使用的连接字符串,
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是适合我的 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";