zoukankan      html  css  js  c++  java
  • 将多个 docx 文件使用 POI 进行合并,生成单个文档,包含图片

    1 添加 maven 依赖,需要使用 poi 的依赖项

    <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-scratchpad -->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-scratchpad</artifactId>
            </dependency>
    
    
            <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi</artifactId>
            </dependency>
    
            <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-ooxml</artifactId>
            </dependency>
    
            <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas -->
            <dependency>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-ooxml-schemas</artifactId>
            </dependency>
    •  对于对个文档合并中间需要添加分页符有两种方式:段前添加分页符、段后添加分页符

    段后添加分页符示例代码

    //段后添加分页符
    XWPFDocument doc;
    XWPFParagraph paragraph = doc.createParagraph();
    paragraph.setPageBreak(true);

    段前添加分页符示例

    //段前添加分页符
    XWPFDocument doc;
    XWPFRun run = doc.getLastParagraph().createRun();
    run.addBreak(BreakType.PAGE)
  • 相关阅读:
    Ubuntu环境下IPython的搭建和使用
    智能移动导游解决方案简介
    企业文化、团队文化与知识共享
    CoinPunk项目介绍
    Insight API开源项目介绍
    比特币Bitcoin源代码安装编译
    Javascript单元测试Unit Testing之QUnit
    Node.js的UnitTest单元测试
    Node.js调试
    Alfresco 4 项目介绍
  • 原文地址:https://www.cnblogs.com/zhaopengcheng/p/9821467.html
Copyright © 2011-2022 走看看