【发布时间】:2021-01-20 17:34:09
【问题描述】:
我正在尝试将 excel 文件(.xlsx、.xlsm 等)中的数据读取到 C# 中,我觉得它应该很简单。我看到的最流行的方法是使用Microsoft.Office.Interop.Excel,但是当我运行它时,我收到了这个错误(keys x'd out)
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxx'. The system cannot find the file specified.
File name: 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxx'
从这行代码
Excel.Application xlApp = new Excel.Application();
我相信这是因为它正在检查 Office 15.0 版,但我有 18.2 版。所以我去 nuget 获取更新版本的软件包,但没有运气,这是最新版本。关于如何解决这个问题的任何建议?我的电脑上没有 Office 版本 15,我不确定我是否能得到它。我在这里做错了什么还是建议了不同的方法?我觉得这将是一个非常普遍的需求,非常感谢任何帮助,提前谢谢!
【问题讨论】:
标签: c# excel office365 version