Click here to Skip to main content
15,891,704 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

Java
hfPolicy.createFooter(
    org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum.forString("Footer.")
  );


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

pls anyone help me out.....


thanks
Andavar.p
Posted
Updated 23-Feb-12 1:59am
v3

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:

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

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

Error:

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(testfooter.java:75)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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