wordpress hit counter
Re: Data-Driven Document Generation (docx) from a Template (dotx) - WordprocessingML - Formats - OpenXML Developer

Re: Data-Driven Document Generation (docx) from a Template (dotx)

Formats

Discussions about working with different Open XML Formats

Data-Driven Document Generation (docx) from a Template (dotx)

  • rated by 0 users
  • This post has 2 Replies |
  • 1 Follower
  • I would like to automate the generation of documents from data stored in an Excel spreadsheet. The task is not to simply replace content controls with text because there is an iterative element - I need to take a template (stored as a Building Block or docPart), make several copies of it and fill in the blanks to produce the final document.

    I have created the docPart in my dotx template and I can see it in glossary/document.xml as a <w:docPart> element. This allows me to edit the style of the repeatable elements using the Word UI.

    What is the best method for generating a docx from this dotx by creating multiple new instances of the <w:DocPart> element and filling in the placeholders with data within each instance?

    I am writing the application as a Windows Forms C#.NET and don't mind using either Interop Automation or the OpenXML SDK - whichever is most useful.

    Any ideas on what I need to read up on?
  • Hi There.

    I'd probably work this up with the Open XML Format SDK. Make sure that you use version 2.0 of the SDK.

    You may find that for the actual content generation it is useful to use XSLT to take your source data (as XML) and use this to generate your docPart (as XML) then use the Open XML Format SDK to package this up.
  • Hello cauld,

    I have very little experience with OpenXML. I was very amused with your reply.

    When you say the actual content generation, what exactly do you mean by that? Can you please elaborate on this technique?

    Why would be the usage of XSLT be beneficial when you can use OpenXML by itself? I am sure there are some advantages. What are they?

    Thanks in advance.
Page 1 of 1 (3 items)