【问题标题】:Could not read the excel file in server无法读取服务器中的 excel 文件
【发布时间】:2017-05-31 12:51:17
【问题描述】:

以下是我读取 excel 文件的代码。这在本地机器上运行良好。但是我把它移到服务器上它返回错误。

            Excel.Application xlApp = new Excel.Application();
            Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(@""+Path);
            Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
            Excel.Range xlRange = xlWorksheet.UsedRange;

【问题讨论】:

  • 你用什么库来阅读它?
  • @JoePhillips 使用 Excel = Microsoft.Office.Interop.Excel;
  • 你能把返回的错误包括在哪一行代码上吗?
  • 你需要在服务器上安装 Excel 但最好使用像样的库而不是互操作

标签: c# excel


【解决方案1】:

原因是因为server-side Automation of Office支持。

可能有很多事情可能会出错。这就是微软从 Office 2003 开始​​采用 XML 格式的原因。

如果您想在服务器上处理 Excel 文件,请按照知识库文章的建议使用 XML 库,例如 ClosedXMLOLEDB

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-14
    • 2019-10-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多