Syntax Highlighting

Tuesday, January 24, 2012

InfoPath to Word? No go.

I've gotten a project where I have to turn a filled out InfoPath form into a Word document. After considerable research on the matter, despite what a lot of people say, it is best left undone. The XSLT you have to create must really be done by hand, and it should produce something you can do by hand. The reason people want it in Word is so that they can format it. However, the natural tendency is to want to format the word document as a template before its fields are populated with the data in the InfoPath. There are various tools in Word or even OpenOffice/LibreOffice to get this done, but the problem is with InfoPath "repeating tables". These are devices the form uses to populate XML structures, but multiples of them. To use this effectively, you need to use:

<xsl:for-each select="my:myFields/my:SomeElement">
  The "." means from the current my:SomeElement.
  <xsl:value-of select"./my:SubElement"/>
</xsl:for-each>


If you unzip the "docx" file you can extract "word/document.xml" and make this document an XSLT transform. However, you cannot load it back look at it as a Word document. So, trying to update the formating of the word document really requires you to start the whole process from the beginning, which is daunting to say the least.

The best way is to create something you can create by hand, such as an HTML document, and use some clever CSS to format it.

No comments:

Post a Comment