tags:

views:

118

answers:

1

Hello,

we are doing quite some invoice generation, and so far it is based on some pretty awful word automation that is now in for a review with Word 2010.

I would love to move to a XML based format for storing / presenting invoices, only going to a word document in the last stage. This means I can use easily othermeans to present an invoice internally from the XML.

We use Word as "last stage" because Word is a lot better than anything else ever discovered for formatting - our invoices have quite some text sometimes, in the invoice item table, and word is smartest with handling page breaks in the "correct" way.

Now, here my question: is there any proper way by now to do this with XML easily? I remember Word having (had) in 2007 some XML field mapping mechanism, but it did not handle tables in the XML. Was anything changed? What would be the proposed approach for generating an .docx document (starting with a .dotx templace) for an invoice, if the relevant data is available in XML form?

+1  A: 

As far as I know there is some mechanism to automate building msword 2007 docs from xml. Main idea is to build xslt transformation on your xml. As you know word document is just an archive(just change extension to .zip and you will see) of different xml's. But problem that it is not always in one xml file(I worked with excel generation - there is a lot xml files there).

Also here is great example how to make exactly what you want - http://www.codeproject.com/KB/office/Generating_Word_Reports.aspx but I was not able to apply this to msexcel documents..

So I prefer to use DocumentFormat.OpenXml and DocumentFormat.OpenXml.Extensions to generate msword or msexcel documents.

mmcteam.com.ua