首页 > 其他分享 >apache.poi设置word页眉页脚

apache.poi设置word页眉页脚

时间:2023-10-30 17:55:04浏览次数:27  
标签:case docx word 页脚 headerFooterPolicy break STHdrFtr 页眉 createHeader

            XWPFDocument docx = new XWPFDocument();
            XWPFHeaderFooterPolicy headerFooterPolicy = docx.getHeaderFooterPolicy();
            if (headerFooterPolicy == null) headerFooterPolicy = docx.createHeaderFooterPolicy();
            String sealType = "";
            sealType = paperTemplate.getPtSealLineType().toLowerCase();
            switch (sealType) {
                case "once":
                    //首页
                   docx.createHeader(HeaderFooterType.FIRST);
                    break;
                case "default":
                    //每页
                    headerFooterPolicy.createHeader(STHdrFtr.DEFAULT);
                    break;
                case "odd":
                    //奇数页
                    docx.setEvenAndOddHeadings(true);
                    headerFooterPolicy.createHeader(STHdrFtr.DEFAULT);
                    headerFooterPolicy.createHeader(STHdrFtr.EVEN);
                    break;
                case "even":
                    //偶数页
                    docx.setEvenAndOddHeadings(true);
                    headerFooterPolicy.createHeader(STHdrFtr.DEFAULT);
                    headerFooterPolicy.createHeader(STHdrFtr.EVEN);
                    break;

            }

标签:case,docx,word,页脚,headerFooterPolicy,break,STHdrFtr,页眉,createHeader
From: https://www.cnblogs.com/javacoffeenet/p/17798462.html

相关文章

  • FastReport 导出Excel、Word、Pdf
    privatevoidExportPDF(H_HistoryDataModelmodel){try{//createreportinstanceReportreport=newReport();PrepareReport(report,model);//createexpor......
  • 页脚 ip地址显示插件
    <scripttype="application/javascript">functiongetgeoip(json){varfooterText="IP地址:"+json.ip+""+"["+json.country+"]";document.getElementById("ip-plugin").innerHTML=fo......
  • Python Wordcloud报错:Only supported for TrueType fonts,多种解决方案
    PythonWordcloud报错:OnlysupportedforTrueTypefonts,多种解决方案。报错内容如下:2023-10-26T09:35:41.190459839ZTraceback(mostrecentcalllast):2023-10-26T09:35:41.190502589ZFile“lib/task/compute.py”,line621,in2023-10-26T09:35:41.190514101Zcompute_......
  • Word docx转html和markdown
    Pypandoc使用pandoc来进行各种文本格式的转换。安装#不带pandoc执行库pipinstallpypandoc#自带pandocpipinstallpypandoc_binary使用importpypandoc#convertallmarkdownfilesinachapters/subdirectory.pypandoc.convert_file('chapters/*.md','docx',outpu......
  • vba 处理word 的一些代码:修改公式(1--1)为(1-1)
    SubConvertSpecificEquationsToText()DimoEqAsOMathDimeqTextAsStringDimregExAsObjectSetregEx=CreateObject("VBScript.RegExp")'DefinetheregularexpressionpatternregEx.Pattern="(\d.?\d)"'Patternfor(di......
  • c# 如何实现把word文件转换成Pdf文件?
    最近开发一个项目,要实现把word文件转换成pdf文件。实现的方案大概分为三种:1、利用微软的库Microsoft.Office.Interop.Word来进行Word到PDF的转换【需要安装office软件】2、利用WPS的COM组件来实现Word到PDF的转换【需要安装wps软件】3、利用商业插件实现Word到PDF的转换【......
  • Gensim库的使用——Word2vec模型
    Word2vec源码   Word2vec论文   Word2Vec原理参考 Gensim库的使用——Word2vec模型pipinstallgensimhttps://ai.tencent.com/ailab/nlp/zh/data/tencent-ailab-embedding-zh-d100-v0.2.0-s.tar.gz762Mtar.gztencent-ailab-embedding-zh-d100-v0.2.0-s.txt1.88......
  • Aspose.Words 自动编号段落提取编号内容
    https://blog.csdn.net/u010187918/article/details/127729231如果提取不成功请确定该段落是否确实具有自动编号,如果确定,那么请在Aspose.Words.Document类对象doc使用doc.UpdateListLabels()接口后再看是否提取成功。  ///<summary>///获取List编号内容///</summary>/......
  • MySQL报'Access denied for user 'root'@'localhost' (using password: NO)'
    当在命令提示符下执行该命令时,报下列错误[root@clvn]#mysqladmin-urootpassword"sorry"mysqladmin:connecttoserverat'localhost'failederror:'Accessdeniedforuser'root'@'localhost'(usingpassword:NO)'解决办法:[root@c......
  • Wordpress Restful API Auth
    1.0Whydoesitnotwork? DELETE|http://127.0.0.1/wordpress.002/wp-json/wp/v2/smokes/20{"code":"rest_cannot_delete","message":"Sorry,youarenotallowedtodeletethispost.","data"......