Search code examples
xmltemplatesms-worddocxopenxml

How to repeat similar fields in a word template?


I am delving into the realm of programmatically editing a word document based on a template. If for example, the template had a section in it for My address, and they wanted my past addresses going back 5 years, and I have moved 3 times, I will have to put in 3 addresses. Obviously the fields here are exactly the same, but I want each of them to have different values. What is the best way to handle this? I guess in the back-end XML document I would expect to see Address1 Address2 Address3 and so on, but not everyone is going to have 3 addresses. Should I just have one location in the template, and make my code inject those other XML sections for an address, hardcoded based on the template?


Solution

  • See http://dbe.codeplex.com/Thread/View.aspx?ThreadId=219510 or http://dev.plutext.org/svn/docx4j/trunk/docx4j/sample-docs/databinding/conventions.docx