开发者

Word 2007 Documents in Visual Studio 2010

开发者 https://www.devze.com 2023-01-01 21:23 出处:网络
I\'m currently using Visual Studio 2010 Professional, and noticed the ability to create Word 20开发者_JS百科07 and Word 2010 documents as add-ins with C#.

I'm currently using Visual Studio 2010 Professional, and noticed the ability to create Word 20开发者_JS百科07 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?


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.


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号