We’ll be assigning tag names to identify content controls for data binding in our code. ![]() With the cursor still positioned after the text “Dear “, click in the Developer tab to insert a new Text content control: Then check the “Show Developer tab in the Ribbon” checkbox and click OK. Click the Office button and choose Word Options. You can add content controls to your document from the Developer tab on the ribbon, but since that tab is hidden by default, you’ll need to show it first. We now want to inject our first content control for the customer name. Start a new document in Word 2007, and type the word Dear followed by a space. We’ll create a simple document with three content controls that will be bound to the following XML data: You can download the SDK from here: Create the Document Once the SDK is installed, you’ll have the assemblies you need to programmatically manipulate Office documents using the OpenXML API. Then we’ll write a small amount of code to embed an XML file into the document and bind the content controls to various elements in the XML.īefore starting, you need to download the OpenXML SDK 2.0. We’ll begin by creating a document with content controls. ![]() And (for a LINQ junkie such as myself, anyway) the best part is that it works so nicely with LINQ to XML. This new feature in Word 2007 delivers the best data/view separation we’ve seen to date in Microsoft Office. In this post, I’ll show you how to use OpenXML to implement bi-directional data binding between a Word document and XML data. The OpenXML file format used by Microsoft Office 2007 enables programmatic document manipulation without automating Word, so that Word does not need to be installed alongside your code, which is great for server applications.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |