Create Word Doc file in Java Using POI

Apache POI is very useful for working on with the MS office files like Word, Excel etc. In the post we will how to create word doc file in java using POI.

Setup for Apache POI

NOTE : For non maven users, you need to download the latest Apache POI jar from here and set it in your classpath along with some other jars.

Classes / Interfaces Used

XWPFDocument

org.apache.poi.xwpf.usermodel.XWPFDocument is used to create the MS Word Docs in the .docx formats.

The Code

Output

When we run the above code we get the message on the console and a blank word document is created at the location we had specified.

Create Word Doc file in Java Using POI

In few of the next posts we will see some of the other stuff we can do with Word documents using Apache POI.

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn