Raghu J Ram
APACHE.POI -- Create word Document
2 Answer(s)      5 years and 2 months ago
Posted in : Development process
Hi,
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
Advertisement
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");

    doc.write(fos);


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");

    doc.write(fos);









Related Tutorials/Questions & Answers: