首页 文章

Excel连接字符串

提问于
浏览
0

我正在尝试阅读Excel,我正在使用的代码在一个项目中运行,并在另一个项目中为相同的Excel输入提供错误"External table is not in the expected format." . 代码失败可能是什么问题? - 我的连接字符串是“ strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties="Excel 8.0;HDR=" + HDR + ";IMEX=0"";

1 回答

  • 0

    您需要在扩展属性值周围放置单引号 .

    from here

    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'");
    

相关问题