未使用POI XWPF createFooter()方法打开Word文档文件 [英] word document file is not opened using POI XWPF createFooter() method
问题描述
亲爱的所有人,
我正在创建Word文档,但我想设置页眉和页脚.我正在使用POI XWPF,这是因为当我尝试使用此方法时我使用了createFooter(Enum type)mehtod,但我从Word document中得到了错误.我的输出文件无法打开在这里..错误信息是
由于内容有问题,无法打开Office Open xml文件temp.docx"//错误说输出我的Word文件
我的代码是
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
hfPolicy.createFooter(
org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum.forString("Footer.")
);
我几乎找不到此解决方案.这是我的源错误或字错误,我完全不知道.....
请任何人帮助我.....
谢谢
Andavar.p
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
推荐答案
这是您关于该问题的3.或4.问题.
使用Java POI设置页眉和页脚 [ ^ ]
我解释说您应该在此处查看文档.该文档为您提供了3个Enum值:
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.DEFAULT);
// hfPolicy.createFooter(oEnum.EVEN);
// hfPolicy.createFooter(oEnum.FIRST);
这篇关于未使用POI XWPF createFooter()方法打开Word文档文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!