Microsoft Interop Excel with .Net5.0 不工作 [英] Microsoft Interop Excel with .Net5.0 is not working

查看:54
本文介绍了Microsoft Interop Excel with .Net5.0 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我现有的 WCF 服务迁移到 .Net5.0 Web API.目前我们有 Excel Interop 依赖来实现 excel 单元格更新,在 excel & 中运行宏.然后捕获特定单元格范围的屏幕截图.

I am trying to migrate my existing WCF service to .Net5.0 Web API. Currently we have Excel Interop dependency to implement excel cells update, running macro inside excel & then capturing the screenshot of specific cell range.

当我尝试使用 nuget 包将 Microsoft Interop 添加到 .Net5.0 时,看到警告,例如它与 .Net Frameworks 以外的不兼容.

When I am trying to add Microsoft Interop with .Net5.0 using nuget package, seeing warning like it is not compatible other than .Net Frameworks.

谁能帮我把 nuget 包添加到 .Net5.0 Web API 项目中?

Can anyone help me is it possible to add nuget package to .Net5.0 Web API project?

推荐答案

正如@Alexey Rumyantsev 所说,Microsoft Interop 无法移植到 .Net 核心,因为它依赖于 Office 互操作.Office 互操作是 Windows 的任何功能.更多细节,你可以参考这个 github issue.

As @Alexey Rumyantsev says, the Microsoft Interop wouldn't be possible to port to .Net core because it relies on the Office interops. The Office interops is windows ony feature. More details ,you could refer to this github issue.

如果您仍然想在asp.net core 中使用Microsoft Interop Excel,我建议您可以尝试创建一个新的.NET Framework 4.X 项目.将相关的 COM 引用添加到项目中.编辑 .NET Core 5.0 项目的 .csproj 并将从 .NET Framework 项目生成的引用添加到标记中.

If you still want to use Microsoft Interop Excel in asp.net core, I suggest you could try to create a new .NET Framework 4.X project. Add the relevant COM references to the project. Edit the .csproj of your .NET Core 5.0 project and add the generated references from the .NET Framework project to the tag.

注意:我们不建议您使用这种方式,我们建议您使用其他 EXCEL 库.

Notice: We don't suggest you use this way, we suggest you use other EXCEL library.

更多细节,你可以参考这个答案.

More details, you could refer to this answer.

这篇关于Microsoft Interop Excel with .Net5.0 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆