0

我正在尝试阅读 Excel,我正在使用的代码在一个项目中运行并给出错误“外部表不是预期的格式”。对于另一个项目中的相同 Excel 输入。代码失败可能是什么问题?- 我的连接字符串是“ strConn =”Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=\"Excel 8.0;HDR=" + HDR + ";IMEX=0\""; "

4

1 回答 1

0

您需要在扩展属性值周围加上单引号。

从这里

1. conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.15.0;Data Source=C:\Users\Input.xlsx;Extended Properties='Excel 15.0 Xml'");
 2. conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.14.0;Data Source="+FilePath+";Extended Properties='Excel 14.0 Xml'");
 3. conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Input.xlsx;Extended Properties='Excel 12.0 Xml'");
于 2017-01-13T10:39:15.067 回答