【问题标题】:Error connecting to excel连接到excel时出错
【发布时间】:2013-04-04 19:06:27
【问题描述】:

我需要以编程方式从特定路径读取 Microsoft Excel 文件。以下代码会导致我以前从未见过的错误消息

string sConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Server.MapPath("Book1.xls") + ";" + "Extended Properties=Excel 12.0 Xml;HDR=Yes"; 
        OleDbConnection con = new OleDbConnection(sConnectionString);
        con.Open();

打开连接时,显示以下错误消息:

Could not find installable ISAM.

有人有与此错误相关的解决方案吗?非常感谢您在这方面的帮助。

【问题讨论】:

    标签: c# .net database-connection oledb export-to-excel


    【解决方案1】:

    根据this question,您必须将属性括在引号中并确保路径不包含空格。

    把你的代码改成

    string sConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + Server.MapPath("Book1.xls") + ";" + "Extended Properties='Excel 12.0 Xml;HDR=Yes'"; 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-06
      • 2016-10-26
      • 1970-01-01
      • 1970-01-01
      • 2022-06-22
      • 2020-04-04
      • 1970-01-01
      相关资源
      最近更新 更多