Search code examples
.netms-wordms-officeopenxmloffice-2007

Repeating content with Office Open XML


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?


Solution

  • 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.