Creating a word document from a template dynamically using values from java objects

Sunmit Girme picture Sunmit Girme · Mar 14, 2012 · Viewed 21.7k times · Source

I want to create a word document from an HTML page. I am planning to get the values on the HTML page and then pass these values to a document template. I have used JSOUP to parse the contents of the HTML page and I get the values in my java program. I now want to pass these values to a word document template. I want to know what are the best techniques I can use to create the document template and pass the values to the template to create the word document.

Thank You.

Answer

Sunmit Girme picture Sunmit Girme · Mar 15, 2012

I found something very Interesting and simple. We just need to create a simple .xml template for the document we want to create and then programmatically change the contents of the xml file and save it as a ms word document.

You can find the xml template and the code here.