How can I use predefined formats in DOCX with POI?
Posted
by furtelwart
on Stack Overflow
See other posts from Stack Overflow
or by furtelwart
Published on 2010-04-15T08:43:34Z
Indexed on
2010/04/15
11:53 UTC
Read the original article
Hit count: 698
I'm creating a docx generator with POI and would like to use predefined formats.
Word includes several formats like Title, Heading 1..10 etc. These formats are predefined in every DOCX you create with Word.
I would like to use them in my docx generator. I tried the following but the format was not applied:
paragraph = document.createParagraph();
lastParagraph.setStyle("Heading1");
I also tried "heading 1", "heading1" and "Heading1" as style, but none of them worked.
The API documentation doesn't show any details.
I analysed a docx file created with Word 2007 and found out "Heading1" would be correct. Unfortunately, the style is not defined in the docx. Do I have to create this style manually?
Can anyone point me to the correct solution?
© Stack Overflow or respective owner