Flexible Word Doc Generation - Architectural Approach Advice RRS feed

  • Question

  • We've done a few simple & rigid doc generation apps already and generally understand the major areas of OpenXml for Word 2007 & Excel 2007 pretty well.  We are NOT experts on all the advanced features of either Word or OpenXml.

    The goal now is to generate a word doc from a template by merging a dozen distinct data blobs into a Word 2007 template.  So far, so easy.  But the end-users can alter the base Word template doc at will without a code change from us.  So our code has to dynamically locate where they want us to poke in each data element and how they want us to format it.  Some data is simple text fields. Others are tabular, wherein we'll retrieve, say, 20 fields in our rowset and they may only want to see 3 columns times however many rows.  It's perfectly OK for them not to use half the data we're making available.

    We've done something like this on a small scale before using (Rich-)Text Content Controls whose title and/or tag attribute map into our data object names.  But that doesn't address things like numeric formatting, nor does it map well into table binding.  And we don't want to invent our own pseudo-markup language which the users would have to include within the body text. e.g. Having them enter "Total Price: {{DataBlob1.Field3:$9,999.00}}" someplace in the body content is not a favored idea.

    We also don't control the end users' machines, so we can't rely on them installing a custom add-in to provide some custom designer behavior.

    I've searched a bunch and all the examples / approaches to document generation that I've found assume we can hard code the doc structure into our generator.  I'm not looking for anybody to design this beast for free, but if anyone has a pointer to any novel implementations of flexible doc generators or has any ideas about other types of landmarks our non-dev users could insert in the template to connect our data to their intent I'd be much obliged.
    Tuesday, March 16, 2010 12:29 AM

All replies

  • Hello Mark, 

    I think the right way for this problem would be to use Custom XML (as we have done in our generator). This would not be totally "install free" solution (you mus bind some xml schem to you word, but it is quite elegant. From the other hand - due patent issues MS have to remove CustomXML feature from upcoming releases so IMHO this is not the way to go... And we also are looking what can be used instead.
    If there should be possibility for the user to change template there should be way to put placeholders for the data. I see two ways to achieve this: 
    1. use existing items (content controls, something else?)
    2. install some addons
    As I understand no one solution fit your neeeds (for me also both of them do not look perfect), so here I see a deadlock ... Maybe somebody will have some other ideas?

    Do not press ->
    Tuesday, March 16, 2010 7:57 AM