Apache POI WP

XWPFDocument document = new XWPFDocument();
XWPFParagraph tmpParagraph = document.createParagraph();
XWPFRun tmpRun = tmpParagraph.createRun();
tmpRun.setText("Apache Sample Content for Word file.");
tmpRun.setFontSize(18);

FileOutputStream fos = new FileOutputStream("data/Apache_newWordDoc.doc");
document.write(fos);
fos.close();

Aspose.Words

Document doc = new Document();
// DocumentBuilder provides members to easily add content to a document.
DocumentBuilder builder = new DocumentBuilder(doc);
// Write a new paragraph in the document with some text as "Sample Content..."
builder.setBold(true);
builder.writeln("Aspose Sample Content for Word file.");
// Save the document in DOCX format. The format to save as is inferred from the extension of the file name.
// Aspose.Words supports saving any document in many more formats.
doc.save("data/Aspose_NewDoc.docx",SaveFormat.DOCX);

Download Source Code

Last edited Mar 26, 2014 at 1:51 PM by shoaibkhan, version 1