Bug 57618

Summary: How to set heading style for a paragraph in a docx file using Apache POI ?
Product: POI Reporter: furkan <furkan.tanriverdi>
Component: XWPFAssignee: POI Developers List <dev>
Status: CLOSED FIXED    
Severity: critical    
Priority: P2    
Version: 3.9-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   

Description furkan 2015-02-23 07:41:13 UTC
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.setStyle("Heading1");    // not working

    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. 

Comment 1 furkan 2015-02-23 09:25:06 UTC
I found a solution in the link below


But If you have another solution without using template file, please let me know :))

Comment 2 Nick Burch 2015-02-23 14:00:28 UTC
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!
Comment 3 furkan 2015-02-23 14:32:07 UTC
OK. What should I do to do so ?