aspsoe 合并多个文档(保证每个文档的第一页在最新的一页)

复制代码
  /**
     * 拼接多个word模板,每个模板分页
     * @param documentList
     * @return
     * @throws Exception
     */
    public static Document AddDocs2Doc(List<Document> documentList) throws Exception {
        if (documentList.size()>0){
            // 取第一个文档作为主文档,将其与的文档合并到它这里
            Document docAll = documentList.get(0);
            for (int i = 1; i < documentList.size(); i++) {
                Document doc = documentList.get(i);
                doc.getFirstSection().getPageSetup().setSectionStart(SectionStart.NEW_PAGE);
                docAll.appendDocument(doc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
            }
            return docAll;
        }
        return null;
    }
复制代码

 

我理解,如果需要连续拼接的话,则将  SectionStart.NEW_PAGE 改为  SectionStart.CONTINUOUS 即可。

posted @   一去二三浪里小白龙  阅读(369)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
历史上的今天:
2021-03-14 HttpMessageNotReadableException: Required request body is missing:
2019-03-14 Transactional cannot be resolved to a type
//增加一段JS脚本,为目录生成使用
点击右上角即可分享
微信分享提示