C# 错误:外部表不是预期的格式
我使用下面的连接字符串读取excel文件C# 错误:外部表不是预期的格式,c#,excel,C#,Excel,我使用下面的连接字符串读取excel文件 connectionString = "Provider=Microsoft.Jet.OLEDB.12.0;Data Source=D:\test2.xlsx;Extended Properties=\'Excel 12.0;HDR=No;\"; 打开时,会引发异常: "External table is not in the expected format" 我在几个站点进行了探索,并按照上面提到的方法更改了连接字符串,然后采用了其他解决方案。但
connectionString = "Provider=Microsoft.Jet.OLEDB.12.0;Data Source=D:\test2.xlsx;Extended Properties=\'Excel 12.0;HDR=No;\";
打开时,会引发异常:
"External table is not in the expected format"
我在几个站点进行了探索,并按照上面提到的方法更改了连接字符串,然后采用了其他解决方案。但是没有一个不起作用。
请引导我解决这个问题。提前感谢。您能在使用此连接字符串的地方发布代码吗?您尝试提取数据的实际代码可能会对您有所帮助。string connectionString=“Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\test.xlsx;Extended Properties=\”Excel 12.0;HDR=否\“;使用(connection=new-OleDbConnection(connectionString)){connection.Open();--------------在这一行,我得到了错误dataTable=connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,null);DataView-DataView=dataTable.DefaultView;DataView.Sort=“TABLE_NAME desc”;dataTable=DataView.ToTable();connection.Close();}这应该对您有所帮助