- Code: Select all
ObjectFactory factory = null;
factory = Context.getWmlObjectFactory();
WordprocessingMLPackage wordMLPackage;
wordMLPackage = WordprocessingMLPackage.createPackage();
String fileName = "Sample.docx";
String filePath = SettingsConfig.getTempFolderPath(fileName);
P pSample = factory.createP();
R rSample = factory.createR();
Text txtSample = factory.createText();
txtSample .setValue("SAMPLE TEXT");
rSample .getContent().add(txtSample );
pSample .getContent().add(rSample );
wordMLPackage.getMainDocumentPart().addObject(pSample );
wordMLPackage.save(new java.io.File(filePath));
this code saves my generated docx file in my workspace. how do i open the generated docx file via java?