office-interop - 有没有办法在 c# 中使用带有版本独立的 interop excel 生成 excel 报告?
问题描述
我正在使用 Visual Studio 2019 并使用 Nuget 安装“Microsoft.Office.Interop.Excel V 15.0.4795.1000”。当我生成 excel 报告时,它可以与“Microsoft Office 2013”一起正常工作。但是,收到“Microsoft Office Home and Business 2019”的错误消息。
错误消息:HRESULT 异常:0x800A03EC 异常:System.Runtime.InteropServices.COMException (0x800A03EC):HRESULT 异常:0x800A03EC
我假设 Office 2019 不支持 Interop Excel V 15。
我使用下面的代码来创建 excel 应用程序。
using ExApp = Microsoft.Office.Interop.Excel;
ExApp.Application xlApp = new ExApp.Application();
后来,我还尝试使用下面的代码,认为它可以与多个版本的 excel 一起使用。
Type ExcelType = Type.GetTypeFromProgID("Excel.Application");
dynamic xlApp = Activator.CreateInstance(ExcelType);
有没有办法可以在任何版本的 excel(2007 到 2019)上用 c# 生成 excel 报告?
至少,我需要“Microsoft Office Home and Business 2019”的解决方案。
解决方案
推荐阅读
- java - 使用 Play 连接到 WebSocket!2.5
- asp.net - 自定义授权过滤器以检查电子邮件确认和资源所有权
- node.js - Uppy 文档未定义 node.js
- c# - MongoDb - 使用 Entityframework Core 查询子集合的最佳实践是什么
- python - 使用边缘检测从图像中裁剪子图像
- sql - Postgres执行合并中的所有子查询
- html - 我的 HTML 文档中有三个相同的 ID,如何使用 CSS 捕获第三个 ID
- java - IntelliJ Idea 错误:异常构建过程终止 - 未能创建子事件循环
- android - 使用数据绑定应用主题时出现编译器错误
- javascript - 使所有选定的 css 圆圈处于活动状态