views:

32

answers:

3

I've been checking out what is possible with the Office Open XML specification for documents. I'm particularly interested in being able to add custom XML content to a document and binding it to content controls. I was wondering if it is possible to have a repeating content control type?

For example, say I have some custom XML in my .docx file that looks like so:

<Work>
  .
  .
  <People>
    <Person>
      <Name>Jane Doe</Name>
      <EmailAddress>[email protected]</EmailAddress>
    </Person>
    <Person>
      <Name>John Doe</Name>
      <EmailAddress>[email protected]</EmailAddress>
    </Person>
  </People>
</Work>

Is there any repeating content control (similar to an ASP repeater) that I could use to generate output that looks something like

If there are no types of controls, I guess I could do some processing on the word document itself to generate a list. Has anyone done this and have some helpful pointers?

A: 

There is not built-in Content Control for repeating content in Word 2007/2010. The following possibilities come to my mind though:

  • Create the full content programmatically using the Open XML SDK. No databinding though.
  • Use Word's MailMerge feature for displaying several similar data sets.
  • Use InfoPath which has better support for repeating content
  • Use a third-party solution such as Windward Reports.
0xA3
Thanks for the pointer to Windward Reports. This looks very useful although I think for what I am doing currently I am going to go with your first bullet and create it programmatically
Dustin Hodges
+1  A: 

As 0xA3 says, there is nothing built-in like this, it would be WordprocessingML-manipulated. But here is an example of pulling data from a database to create multiple entries: Pushing Data from a Database into a Word Document.

Also, on the subject of databinding in general, here is a good starter tutorial: Linking Word 2007 Content Controls to Custom XML.

Otaku