c# - 错误外部表不是预期的格式

标签 c# excel oledb

我正在尝试通过 visual studio-2008 中的 oledb 连接从 sheet1.xls 文件获取数据到 sqlserver2005 我的 C# 应用程序,我使用的是 windows7 操作系统而且我没有在我的系统上安装 excel。

这是我的连接字符串:

 string excelconnectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +excelfilepath + ";"+"Extended Properties='Excel 8.0;HDR=Yes;'";

我尝试了很多方法,但仍然出现此错误:

"External table is not in the expected format. "

请帮帮我。

最佳答案

对 excel 文件使用 Microsoft.ACE.OLEDB.12.0

string excelconnectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +excelfilepath + ";"+"Extended Properties="Excel 12.0;HDR=Yes";

connectionstrings

关于c# - 错误外部表不是预期的格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21521817/

相关文章:

c# - 在条件执行之前从 NHibernate 条件获取 SQL 查询

c# - Cassandra 插入性能 c#

c# - VSTO 2012 : backward compatibility

c# - 使用 OLEDB + 某些单元格未加载数据的问题读取 .xlsx 文件

delphi - 尝试访问 Delphi 7 中的 Excel 表时的提供程序选择

c# - 如何检测是否调试

c# - services.AddSingleton,永远不会调用服务的构造函数

c - 从C读取Excel文件

Excel VBA - For 循环需要跳过网页抓取中的第一个元素

c# - 为什么用第一个读者 read() 运行第二个读者比在它自己的读者阅读上运行它运行得更快?