How do I create a formatted Microsoft Word document from Java?
Created May 4, 2012
Stephen Silber [More Q: (I know how to set the content-type from a servlet, but I require formatted bordered table oriented output in the word doc.) ]
The simplest way, since the Word format is messily binary, is to write out an RTF file, which is mostly ASCII-oriented. This technique works just well--check out the RTF output from an SEC filing at www.FreeEDGAR.com to see some nice examples of programmatically-generated RTF.
The RTF spec is at http://msdn.microsoft.com/library/default.asp?PP=/library/toc/specs/specs10.xml&tocPath=specs10&URL=/library/specs/rtfspec.htm
[See also http://www.jguru.com/jguru/faq/view.jsp?EID=3696]