I am trying to create heading titles in a word (.docx) document, using apache-poi.
I have a template which contains only custom styles AND example of heading titles using the custom styles.
XWPFDocument document=new XWPFDocument(new FileInputStream("template.docx"));
My custom style is called "CUSTOM_YNP" (I created it directly in Word), but when I use the line below, it returns false
document.getStyles().styleExist("CUSTOM_YNP")
And, of course, when I try to use this style, it doesn't work, actually it print my string in "Normal" style
XWPFParagraph paragraph=document.createParagraph();
paragraph.setStyle("CUSTOM_YNP");
XWPFRun run=paragraph.createRun();
run.setText("TEST");
Just for the record, my "save document" line :
document.write(new FileOutputStream("myDoc.docx"));
I have read this question, but can't actually find a solution to my problem... How can I use predefined formats in DOCX with POI?
EDIT : It works if I create my own style using Apache-POI.... Still I woudl really like to use existing styles from the word document.