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
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.
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?
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 http://support.microsoft.com/kb/257757.
-Eric
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.
Cheers!
Whitney D.
Visit us at SpurPress!
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
Eric White said,
April 22, 2015 @ 12:39 am
Hi,
You may be interested also in some of the other content at this link:
http://www.ericwhite.com/blog/map/generating-open-xml-wordprocessingml-documents-blog-post-series/
The link to download the code is in the “Release of V2” post. Here it is:
https://skydrive.live.com/redir?resid=5E385848AF211BA9!5731&authkey=!AOs_0PT_ICgWjcg
Cheers, Eric