Word 文档替换文本并保存到新文件 [英] Word Document Replace Text and save to a new file
问题描述
我在网上看到了一些关于如何替换 Word 文档中文本的主题,但我真正的问题是:Interop 是最佳选择吗?还有其他(更好)的选择吗?
I've seen a few topics over the web of how to replace text in a Word Document, but my real question is the following: Is Interop the best option? Is there any other (better) option?
这是我读过的一个主题示例LINK.
Here is an example of a topic I've read LINK.
我正在尝试安排一些可以在 Web 服务器上运行良好的东西,所以我也想问你们是否可以提供一些代码来帮助我入门.
I'm trying to arrange something that will work great on a Web Server, so I'm asking too if you guys could provide some code to get me started.
谢谢!
推荐答案
这是一个非常难以回答的问题,因为它涉及关于最好的任何定义中关于哪个最好的很多意见.
This is a very difficult question to answer since it involves that much opinions about which is best, in any definition of best.
作为初学者,我肯定会选择 VSTO/interop,因为它更容易使用,并且与两种产品(Office 和 Visual Studio)的开发人员集成并由其维护.
As a starter I would definitely go for VSTO / interop since it is easier to go, and is integrated with and maintained by the developer of both products (Office and Visual Studio).
如果您需要它在服务器上运行(例如使用 ASP.NET),您应该永远使用 VSTO/interop.
If your require it to run on a server (with ASP.NET for example) you should NEVER use VSTO / interop.
为什么?
这是微软所说的.
Office 互操作不是为了在服务器上作为进程运行而构建的.它太重了,取决于渲染的 UI 功能等.您可以使用 打开 XML for Word 或 EPPlus for Excel 例如.
Office interop is not built to run on a server as a process. It is too heavy, and depends on the UI capabilities for rendering, etc. You could use Open XML for Word or EPPlus for Excel for example.
这篇关于Word 文档替换文本并保存到新文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!