The WordML functionality is implemented in the P2WordXMLFiller class in the Helper assembly.
For the usage of the WordML functionality a MS Word file must be saved in the XML format and can be used as a template. The location of all templates can be configured in the XAppConfig table ConfigName: "WordTemplateLocation".
An example can be found in the FiTransaction module OnFiTransactionPrintExecute. A sample template can be downloaded
here.
P2.Cuberry.Framework.Helper.WordMailMerge.
P2WordXMLFiller filler = new P2.Cuberry.Framework.Helper.WordMailMerge.P2WordXMLFiller();
filler.fillWordXML(
"FiTransactionX2.xml", Path.ChangeExtension (Path.GetTempFileName(),"xml"), Service.RetrieveFiTransactionWithItemsAsDataSet(this.FiTransactionHeaderID));
The filler method takes the name of the xml template and a DataSet with all DataTables used in the template.
In our sample template file we use mail merge fields. Sometimes MS Word saves additional information so the replacement functionality failes to replace all fields. In this case the XML file needs to be edited in Notepad or in another editor.
I our example we use a header DataTable and two Sub-DataTables (TransactionHeader, TransactionItems Debit and TransactionItems Credit). To locate the tables for the two Sub-DataTables we have to place a bookmark in the template file at the first cell of each table.
The bookmark must include the name of the Sub-DataTable and the string "WMLRepeat", e.g. "FiTransactionItemCreditWMLRepeat2".
To find the bookmarks in our sample template you have to open the template in MS Word and click on "Bookmark" in the menu.