Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Answers Viewqa Development-process APACHE.POI -- Create word Document

View Questions and Answers by Category


Have Programming Question? Ask it here!

Raghu J Ram
APACHE.POI -- Create word Document
2 Answer(s)      4 years and 11 months ago
Posted in : Development process

Could any one please post the code which creates the word document having different paragraphs and two tables.
i have sample code "Hello World!!! HAHAHAHAHA I DID IT!!" where we get this code everywhere. But i need to write more to the document like Table inserting values init, aligning text in different formats.
So please anyone please reply the code which creates MS Word in Java...

Raghu J

View Answers

October 23, 2012 at 8:43 AM

Here is the code how to copy a MS word document using java, with all formatting from one document to other -

FileInputStream in = new FileInputStream("source.docx");

    XWPFDocument doc = new XWPFDocument(in);

    FileOutputStream fos = new FileOutputStream("destination.docx");


October 23, 2012 at 8:49 AM

will copy the MS word document from test1.docx to result.docx using Apache POI.

required jars - xml-beans-2.3.0.jar dom-4j-1.5.jar poi-3.8.x.jar s-beans-2.1.jar poi-ooxmll-schemas.jar

FileInputStream in = new FileInputStream("test1.docx");

    XWPFDocument doc = new XWPFDocument(in);
            FileOutputStream fos = new FileOutputStream("result.docx");


Related Tutorials/Questions & Answers: