Mail merge from Java

Mike Q picture Mike Q · Mar 4, 2010 · Viewed 12.2k times · Source

Does anyone have any experience with doing mail merge from Java on a word document? I need to support both doc and docx formats.

I have heard of Apache POI and docx4j. However, from reading around I'm sure how good the word support is in POI. docx4j only supports docx format as far as I can see.

Can any suggest either one of the above (and correct my knowledge on support) or another appropriate library. If necessary I would be willing to use one lib for doc and another for docx.

Thanks.

Answer

Piotr Kochański picture Piotr Kochański · Mar 5, 2010

Working with MS Word documents is very hard. DOC format is very complicated, DOCX is in theory simpler, but it is rather new and there is no mature, feature rich Java library to work with it and DOC as well.

The easiest solutions to most problems connected with working with MS Office documents is describe in the Joel Spolsky article. I hope you can use this method in your application.