031.java代码实现多个world合并

在业务实践中往往会遇到数据的导出,world可以最直观将实际情况反馈出来,有些固定描述页签不需要业务编写,那么我们可做固定world,将导出world和固定world进行合并,进行多个world合并,下面我是将N(4)个world进行合并,直接上代码

import com.aspose.words.Document;
import com.aspose.words.ImportFormatMode;
import com.aspose.words.ImportFormatOptions;
import com.aspose.words.SaveFormat;

public class testController {

    public static void main(String[] args) {
        String wendang1 = "E:/wendang1.doc";
        String wendang2 = "E:/wendang2.doc";
        String wendang3 = "E:/wendang3.doc";
        String wendang4 = "E:/wendang4.doc";
        String zhuanzhe1 = "E:/zhuanzhe1.doc";
        String zhuanzhe2 = "E:/zhuanzhe2.doc";
        String zuizhong = "E:/zuizhong.doc";
        testMain(wendang1,wendang2,wendang3,wendang4,zhuanzhe1,zhuanzhe2,zuizhong);
    }
    /**
     * world合并
     * @param overhaulPage :文档一
     * @param overhaulPicturePage :文档二
     * @param pjManagerPage :文档三
     * @param proprietorPage :文档四
     * @param IntermediatePage :中间转折页【检修详情页、检修详情页(图片)】
     * @param IntermediatePageSec :中间转折页2【中间转折页[检修详情页、检修详情页(图片)]、项目经理工程师签字页】
     * @param finallyPage :最终生成页
     */
   public static void testMain(String overhaulPage, String overhaulPicturePage, String pjManagerPage, String proprietorPage, String IntermediatePage, String IntermediatePageSec, String finallyPage) {
        try {
            Document doca = new Document(overhaulPage);
            Document docb = new Document(overhaulPicturePage);
            ImportFormatOptions importFormatOptions = new ImportFormatOptions();
            importFormatOptions.setIgnoreHeaderFooter(true);
            doca.appendDocument(docb, ImportFormatMode.USE_DESTINATION_STYLES,importFormatOptions);
            doca.save(IntermediatePage, SaveFormat.DOCX);

            Document docc = new Document(IntermediatePage);
            Document docd = new Document(pjManagerPage);
            ImportFormatOptions importFormatOptions2 = new ImportFormatOptions();
            importFormatOptions2.setIgnoreHeaderFooter(true);
            docc.appendDocument(docd, ImportFormatMode.USE_DESTINATION_STYLES,importFormatOptions2);
            docc.save(IntermediatePageSec, SaveFormat.DOCX);

            Document doce = new Document(proprietorPage);
            Document docf = new Document(IntermediatePageSec);
            docf.appendDocument(doce, ImportFormatMode.USE_DESTINATION_STYLES,importFormatOptions2);
            docf.save(finallyPage, SaveFormat.DOCX);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}

引用maven

<dependency>
    <groupId>com.luhuiguo</groupId>
    <artifactId>aspose-cells</artifactId>
    <version>23.1</version>
</dependency>

<dependency>
    <groupId>com.luhuiguo</groupId>
    <artifactId>aspose-words</artifactId>
    <version>23.1</version>
</dependency>

测试准备:创建需要合并的文档wendang1.doc、wendang2.doc、wendang3.doc、wendang4.doc其中也要创建出两个world合并过程中使用到转折world,zhuanzhe1.doc、zhuanzhe2.doc,和最终合并结束得到的world,zuizhong.doc

四个文档中写了分别写了古诗春晓的内容,合并前的内容

 

 

最终得到的效果

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值