By Vijayeta Tilak of Sonata-Software Limited
The Article describes an application which demonstrates the use of content controls and custom XML to map data to each of these content controls in the word document.
This application uses System.IO.Packaging API (in .NET Framework 3.0) and is freely downloadable.
To make use of these features of the new Office 2007, the application generates sample invoices to a particular organization which holds details about all the Expenses and Contract work assigned.
In this example, each of the invoice documents is identified by a distinct invoice number, say to one particular organization. All the invoice numbers are listed out to the user, for him to select the information he wants to view about that invoice.
On selection of a number from the drop down box, the application displays all the information present for the selected invoice document.
The user can also view the sample of the document that would be generated, by clicking on the link provided.
The UI is as shown here:
Fig.1
When the button ‘Create Document’ is clicked, the application does the following processes
1. Creates XML document from the database table which holds all the information regarding the invoice selected.
2. The XML file is then added to the document package to be created.This XML file would serve as custom XML in the word document package to be generated.
3. Generates content controls in the word document to be generated, depending on the data provided by the XML file generated from the database table.
4. Map data from the custom XML file to each of the content controls, using XML Mapping.
Once the document ids created, it can be downloaded from the link provided.
The resulting document wolud be,
This is a basic application that only allows the user to view the data. It can be enhanced to upload a existing document and change the contents, and also generate multiple documents.