复制Word文档的内容并粘贴到另一个文档中
如何使用 C# 以编程方式复制一个 Word 文档的内容并将其粘贴到另一个 Word 文档?
我基本上想复制一份个人资料(这是一个单词文档的内容),然后将其插入报告中。
任何帮助将不胜感激
谢谢
How do i programatically copy the contents of one word document and paste it to another word document using C#?
I basically want to copy a personal profile (which is the contents of one word doc) and then insert it into a report.
Any help would be greatly appreciated
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
你可以这样做:
You can do this:
你可以这样做:
You can do this:
假设使用 docx,请使用 http://powertools.codeplex.com/ 的 DocumentBuilder 组件
有关详细信息,请参阅< a href="http://blogs.msdn.com/b/ericwhite/archive/2009/02/05/move-insert-delete-paragraphs-in-word-processing-documents-using-the-open-xml- sdk.aspx" rel="nofollow">http://blogs.msdn.com/b/ericwhite/archive/2009/02/05/move-insert-delete-paragraphs-in-word-processing-documents-using- the-open-xml-sdk.aspx
Assuming docx, use the DocumentBuilder component of http://powertools.codeplex.com/
For more information, see http://blogs.msdn.com/b/ericwhite/archive/2009/02/05/move-insert-delete-paragraphs-in-word-processing-documents-using-the-open-xml-sdk.aspx
这个链接应该有帮助。
使用 OpenXml 和 C# 复制 Word 文档
另一个建议是创建副本Word 文件的名称并将其重命名为所需的名称(如果适合您的解决方案)。
http://www.dotnetperls.com/file-copy
This link should help.
Duplicating Word document using OpenXml and C#
Another suggestion is to creating a copy of the word file and renaming it to whatever the required name is, if that suits your soluition.
http://www.dotnetperls.com/file-copy
如果您需要访问较旧的 Word 文档(Word 97 等),可以使用第三方库,这些库使您可以完全控制文档的创建和修改,而无需在目标计算机上安装 Word。这对于网络服务器特别有用。
我们过去曾成功使用 Syncfusion 的 Essential DocIO - http://www.syncfusion.com /products/reporting-edition/docio
否则,您可以使用 Microsoft Office Automation 库访问旧版 Word 文档 - http://support.microsoft.com/kb/301659
使用自动化库时,有很多事情需要小心,因为它们直接在目标计算机上执行 Word。在网络服务器上运行它们是一个很大的禁忌。
If you need to access older Word documents (Word 97 etc), there are third-party libraries available which give you full control over creating and amending the documents without having Word installed on the target machine. This is especially useful for web servers.
We have used Essential DocIO from Syncfusion successfully in the past - http://www.syncfusion.com/products/reporting-edition/docio
Otherwise, you can use the Microsoft Office Automation libraries to access older Word documents - http://support.microsoft.com/kb/301659
There are quite a few things you have to be careful with when using the automation libraries since they execute Word directly on the target machine. Running them on a web server is a big no-no.