I am trying to create a docx file with poi but I cannot set heading style for a paragraph. My code structure is like below; XWPFDocument document= new XWPFDocument(); //Write the Document in file system FileOutputStream out = new FileOutputStream(new File("C:/Users/2/Desktop/RequirementModelDocument.docx")); XWPFParagraph paragraph = document.createParagraph(); XWPFRun run=paragraph.createRun(); paragraph.setAlignment(ParagraphAlignment.LEFT); paragraph.setStyle("Heading1"); // not working run.setText(reqLevel.getName()); run.setBold(true); run.setFontFamily("Calibri Light (Headings)"); Its like ignores the paragraph.setStyle("Heading1"); line. I've looked at the apache's examples but I could not see any. regards
I found a solution in the link below http://stackoverflow.com/questions/2643822/how-can-i-use-predefined-formats-in-docx-with-poi But If you have another solution without using template file, please let me know :)) regards
If you'd like to write this us as an Example, which we can then ship with POI to help others in future, we'd love to have your contribution!
OK. What should I do to do so ?