在 ASP.net MVC6 网站上使用 Office 互操作 [英] Use Office Interop on ASP.net MVC6 website

查看:11
本文介绍了在 ASP.net MVC6 网站上使用 Office 互操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的 ASP.net MVC 6 网站生成 word 文档.我已经实现了几种在 POC 中生成文档的方法:DocX、NetOffice、OpenXml、COM Interop 对象.我被它诱惑了.

I want to generate word documents from my ASP.net MVC 6 website. I've implemented several ways to generate a document in a POC : DocX, NetOffice, OpenXml, COM Interop objects. I was seduced by it.

我制作了一个控制台应用程序进行测试,它可以工作.

I made a Console App to test and it works.

但是,对于 ASP.net MVC6,我们不能引用控制台应用程序或 COM 程序集.我们需要创建控制台应用程序(包)".

But, with ASP.net MVC6, we can't reference Console App's or COM Assemblies. We need to create "Console App (Package)".

如何将 COM 程序集添加到我的 ASP.net MVC 6 网站?

How can I add COM Assemblies to my ASP.net MVC 6 website ?

推荐答案

Microsoft 目前不推荐也不支持从任何无人值守、非交互式客户端应用程序或组件(包括 ASP、ASP.NET、DCOM 和 NT 服务),因为当 Office 在此环境中运行时,Office 可能会表现出不稳定的行为和/或死锁.

如果您要构建在服务器端上下文中运行的解决方案,您应该尝试使用已确保无人值守执行安全的组件.或者,您应该尝试找到允许至少部分代码在客户端运行的替代方案.如果您使用来自服务器端解决方案的 Office 应用程序,该应用程序将缺少许多成功运行所需的功能.此外,您将在整体解决方案的稳定性方面承担风险.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.

您可以在 Office 服务器端自动化的注意事项文章.

考虑使用为服务器端执行而设计的第三方组件,或者如果您处理开放 XML 文档,您可以使用 Open XML SDK,请参阅 欢迎使用 Open XML SDK 2.5 for Office 了解更多信息.

Consider using third-party components designed for the server-side execution or if you deal with open XML documents you may use the Open XML SDK, see Welcome to the Open XML SDK 2.5 for Office for more information.

这篇关于在 ASP.net MVC6 网站上使用 Office 互操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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