在 ASP.NET IIS 服务器上安装 Office:优点/缺点?
首先,我脑子里的小声音尖叫着,这是一个坏主意,不应该这样做,但我务实的一面却在问“这能有多糟糕?”
严峻的事实是,我公司的大部分日常“业务”都是通过某种 MS Office 工具进行的。数据从我们的自定义工具导出为 *.tab、*.csv,在 Excel 中进行操作,然后以不同程度的成功导入回来。
大多数自定义工具都是 ASP.NET MVC Web 应用程序,其可用性可以通过与 Office 的更多互操作性来增强。
多年来,我一直在为网络服务器上的 Office 进行斗争,认为这是一个糟糕的主意。最近我一直认为增强的可用性超过了潜在的风险。
我要疯了吗?
First off, the little voice inside my head is screaming that this is a bad idea and it shouldn't be done, but my pragmatic side is asking "How bad could it be?"
The stark fact is most of my company's day to day "business" happens in one MS Office tool or another. Data is exported out of our custom tools as *.tab, *.csv, manipulated in Excel and imported back in with variying degrees of success.
Most of these custom tools are ASP.NET MVC web applications whose usability could be enhanced by more interoperability with Office.
I've fought the good fight for many years saying Office on a web server is a terrible idea. Lately I've been thinking that the enhanced usability outweighs the potential risks.
Am I going crazy?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您没有说明您在工作场所使用的 MS Office 版本或您想要什么类型的互操作性。
如果您想直接从 Web 应用程序“即时”生成 Office 文档,那么如果您使用的是 Office 2007 或 2010,则默认文档格式(.docx、.xlsx)基于 开放 XML SDK。这意味着无需在 Web 服务器上安装 MS Office 即可动态生成文档。
如果您使用的是 Office 2003 或更早版本,通常认为在服务器上安装 MS Office 是不好的做法 - 这是不受支持的配置。
这篇 Microsoft 文章概述了如果您决定采用此方法可能会遇到的许多问题。
You don't say what version of MS Office you are using in your workplace or what type of interoperability you are after.
If you want to generate Office documents 'on the fly' directly from the web application, then if you are using Office 2007 or 2010, the default document formats (.docx, .xlsx) are based on the Open XML SDK. This means that it is possible to generate documents dynamically without having to install MS Office on the web server.
If you are using Office 2003 or earlier, it is generally considered bad practice to install MS Office on the server - it is an unsupported configuration.
This Microsoft article outlines many of the possible issues you may face if you decide to go down this route.
Microsoft Office 不适用于在高度分布式、多线程环境的服务器中工作。顺便说一句,它是一个客户端应用程序,主要是非托管代码。因此,安装它并从 Web 服务器使用它可能会隐藏潜在的问题:泄漏句柄、GDI 对象、托管/非托管内存之间的编组、STA COM 对象等。我建议您仅使用设计用于在服务器环境。
Microsoft Office is not designed to work in a server which could be a highly distributed, multithreaded environment. It is a client application which by the way is mainly unmanaged code. So installing it and using it from a web server could hide potential problems: leaking handles, GDI objects, marshaling between managed/unmanaged memory, STA COM objects, etc. I would recommend you using only tools which have been designed to be used in a server environment.
无需在网络服务器上安装office,即可创建良好的office文档。选项包括 SpreadsheetML、来自 aspose.net 的组件,甚至只是更改 html 响应的文件扩展名和内容类型来愚弄 Office 本身。
You can create good office documents without installing office on the web server. Options include SpreadsheetML, components from aspose.net, and even just changing the file extension and content type on html responses to fool office itself.
如果您不想安装完整的 Office 套件,那么您可以只安装 Microsoft Office Primary Interop Assemblies 吗?
http://msdn.microsoft.com/en-us/库/aa159923(office.11).aspx
If you do not want to install the full Office suite, then you can just install the Microsoft Office Primary Interop Assemblies?
http://msdn.microsoft.com/en-us/library/aa159923(office.11).aspx
我见过这种方法在负载非常低的环境中工作......但是一旦负载增加,问题就会开始蔓延。正如 Jazza 指出的文章清楚地表明的那样,微软甚至已经记录了这一点。请注意,这篇文章是最近发表的(2010 年 7 月)。
我见过的问题包括内存泄漏、Word/Excel 实例未卡在内存中、奇怪的注册表问题等等。
另一件需要考虑的事情是,如果您致电他们询问与服务器环境上的 Office 相关的问题,Microsoft 将不会为您提供支持。
同样,如果您只有几个用户,这最初对您来说可能不是问题,但要为规模问题做好准备。
I've seen this work in environments with very low loads...but as soon as the load increases the issues start to creep up. This has even be documented by Microsoft as the article pointed by Jazza clearly shows. Notice that this article is quite recent (July/2010).
The issues that I've seen are memory leaks, instances of Word/Excel not being stuck in memory, weird registry issues, and so on.
Another thing to consider is that Microsoft will not support you if you call them with issues related to Office on a server environment.
Again, if you only have a few users this might not be a problem for you initially but be prepared for scale issues.