Video of use of Document Generation Example

I have completed a rough first version of this document generation system that is driven by C# code that you write in content controls in a Word document.  As an intro, I’ve recorded a small screen-cast that shows the doc gen system in action.

This post is the tenth in a series of blog posts on generating Open XML documents. Here is the complete list: Generating Open XML WordprocessingML Documents Blog Post Series

Demonstrates an approach to Open XML WordprocessingML document generation that uses C# code in content controls.

V1 of the code that enables this approach to document generation is less than 400 lines of code, so this counts as simply an example program.  This shows the value of using functional programming, meta programming, and Open XML to reduce program size.

I have to note at this point – the example program contains almost no error handling.  If you mistype code in the content controls, you will encounter interesting compiler errors after loading the generated program.  In the long run, I expect to resolve these issues in an interesting way.  While at this point, I’m just playing around with document generation ideas, in the future, I want to build a system that is easy and convenient for non-developers to use.

I plan on posting this code sometime early next week, as well as a video that explains in more detail how the doc gen system works.



  1. Otaku said,

    March 2, 2011 @ 8:59 pm

    This is brilliant! Love the video format presentation, its cuts down on time-to-understanding signficantly.

    I did have one question for this type of docgen solution – under what business circumstance would it be used differently from what a mail merge would be? Or is just a different technical approach to the same problem?

  2. Eric White said,

    March 2, 2011 @ 10:35 pm

    Hi Otaku,

    This solves the same problem, more or less, as mail merge. However, this will operate at scale. While using Word itself is not server-friendly, after creating the template document, this example is not using any server-unfriendly technologies, so using this approach, you could reliably generate 100,000 documents in a day. Using this approach combined with Word Automation Services means that you can develop an application that can predictably and reliably generate as many Word, PDF, or XPS documents as you require. I’m going to record another screen-cast that tests this premise, and generate a large number of documents in a short amount of time.

    There are a wide variety of issues when automating Word (which is what mail merge does). See


  3. Whitney Davidson said,

    April 14, 2012 @ 12:21 pm

    This is a very helpful blog. Thank you so much. I would like to have this used by the rest of my colleagues.


    Whitney D.
    Visit us at SpurPress!

  4. Zeeshan said,

    April 21, 2015 @ 1:27 pm

    Its good piece of work. I am looking for the same thing. From where I can get the code of this project?
    Thank you

  5. Eric White said,

    April 22, 2015 @ 12:39 am


    You may be interested also in some of the other content at this link:

    The link to download the code is in the “Release of V2” post. Here it is:!5731&authkey=!AOs_0PT_ICgWjcg

    Cheers, Eric

RSS feed for comments on this post · TrackBack URI

Leave a Comment