Visual Studio 2010 中的 Word 2007 文档
我目前正在使用 Visual Studio 2010 Professional,并注意到能够使用 C# 将 Word 2007 和 Word 2010 文档创建为加载项。
我想要做的是在我的 C# 应用程序中填写包含信息的报告类型文档,然后输出最终的 .docx。使用此功能是否可以实现这一点?我该如何去做?
I'm currently using Visual Studio 2010 Professional, and noticed the ability to create Word 2007 and Word 2010 documents as add-ins with C#.
What I'm looking to do is fill in a report-type document with information in my C# application, and then output the final .docx. Is this possible using this feature, and how do I go about doing it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您所看到的称为 VSTO (Visual Studio Tools for Office) 。它是一种创建和管理客户端实例化的加载项、模板和文档的方法(或者像某些人那样,仅控制客户端的特定操作)。它带来了大量的开销。
听起来您想要的是 Open XML SDK 2.0。这将提供创建 Word(和其他 Office)文档的完全访问权限,无需 Word 客户端或程序或创建它们的操作系统的 VSTO 要求(VSTO 运行时、主互操作等)。关于 OpenXML SDK 有大量信息 - 一个很好的起点是 http://www.openxmldeveloper.org< /a>.另一个是操作方法视频。
What you're seeing is called VSTO (Visual Studio Tools for Office). It's a way to create and manage client-instantied add-ins, templates and documents (or, as some do, just control the client for particular operations). It comes with a lot of overhead.
It sounds like what you want instead is the Open XML SDK 2.0. This will give full access to creating Word (and other Office) documents without any need for the Word client or the VSTO requirements (VSTO runtime, Primary Interops, etc.) for the program or on the OS that is creating them. There is a great deal of information out there on the OpenXML SDK - a good starting point is http://www.openxmldeveloper.org. Another, is How-To videos.
请问,
我为此目的使用了 MS Word 的内容控件。比书签效果更好(可以填充多个具有相同名称的控件,这与重复数据必须具有唯一书签名称的书签不同)。
这里是一个很好的演练/教程,介绍如何使用 Word 200、C#、ASP.Net 逐步执行此操作(示例代码也在其中)
Will,
I have used MS Word's Content Controls for this purpose. Works better than BookMarks (multiple controls with same name can be populated, unlike bookmarks where repeating data has to have unique bookmark names).
Here is a nice walk-through / tutorial on how to do this step by step using Word 200, C#, ASP.Net (sample code also in there)