Click here to Skip to main content
15,919,028 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

I was creating word document but i want to set header and footer.I am using POI XWPF here it is i have used createFooter(Enum type) mehtod when i try to use this method i got error from word document.My output file cant open here..the error message in word is

"The office open xml file temp.docx cannot be opened because problem with the contents" //Error says output my word file

my code is


i hardly find this this my source error or word error exactly i dont know.....

pls anyone help me out.....

Updated 23-Feb-12 1:59am

1 solution

This is your 3. or 4. question regarding that issue.

set header and footer using java POI[^]

I explained that you should check out the documentation there. The documentation gives you 3 Enum values:
static org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum.DEFAULT 
static org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum.EVEN 
static org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum.FIRST 

Choose one from these:

Enum oEnum =  org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum; // to make a long path short

// hfPolicy.createFooter(oEnum.EVEN);
// hfPolicy.createFooter(oEnum.FIRST);
Share this answer
Andavar Perumal 23-Feb-12 6:59am    
when i putting in this my program i got error red mark in Enum oEnum line


java.lang.RuntimeException: Uncompilable source code - cannot find symbol
symbol : variable Enum
location: interface org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr
at org.apache.poi.xwpf.testfooter.main(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900