how to open a generated docx file
Posted: Wed Apr 24, 2013 3:06 pm
I am currently doing a program that generates docx files. and with docx4j i can successfully save it without any problems. but now i need to make an option where the user can view the docx file instead of saving it. how do i do this using java? here's my sample program
this code saves my generated docx file in my workspace. how do i open the generated docx file via java?
- 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?