当前位置: 首页 > news >正文

spire.doc合并word文档

文章目录

  • spire.doc合并word文档
  • 1. 引入maven依赖
  • 2. 需要合并的word
  • 3. 合并文档代码
  • 4. 合并结果

spire.doc合并word文档

1. 引入maven依赖

	<repositories><repository><id>com.e-iceblue</id><name>e-iceblue</name><url>https://repo.e-iceblue.cn/repository/maven-public/</url></repository></repositories>
	<dependency><groupId>e-iceblue</groupId><artifactId>spire.doc.free</artifactId><version>5.2.0</version></dependency>

2. 需要合并的word

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3. 合并文档代码

package com.spire.demo;import com.spire.doc.Document;
import com.spire.doc.FileFormat;public class MergeDocDemo {public static void main(String[] args) {String file1 = "D:\\poiword\\wd\\hb\\测试合并文档1.docx";String file2 = "D:\\poiword\\wd\\hb\\测试合并文档2.docx";String file3 = "D:\\poiword\\wd\\hb\\测试合并文档3.docx";String mergeFilePath = "D:\\poiword\\wd\\hb\\合并文档.docx";Document document = new Document(file1);//将文档file2内容完全插入到文档file1document.insertTextFromFile(file2, FileFormat.Docx_2013);//将文档file3内容完全插入到文档file1document.insertTextFromFile(file3, FileFormat.Docx_2013);//合并后的文档保存到mergeFilePathdocument.saveToFile(mergeFilePath, FileFormat.Docx_2013);}
}

4. 合并结果

在这里插入图片描述

http://www.lryc.cn/news/287328.html

相关文章:

  • 蓝桥杯官网填空题(01串的熵)
  • 【CodeTop】TOP 100 刷题 51-60
  • k8s的图形化工具---rancher
  • npm安装卡住问题(最新版)
  • 什么是线程死锁
  • Django从入门到精通(二)
  • 建筑物防雷检测安全接地应用解决方案
  • 支付宝小程序开发踩坑笔记(支付宝、学习强国小程序)
  • 如何降低微服务复杂度丨云栖大会微服务主题分享实录
  • openresty 安装, nginx与 openresty
  • puppeteer实现截图
  • 【2024Java面试突击】并发编程、线程池面试实战
  • ASUS华硕无畏Pro15笔记本电脑(M6500QB,M6500QH)工厂模式原厂OEM预装Windows11.22H2系统 含Recovery恢复
  • 代码随想录算法训练营第三十天|51. N皇后
  • Kubernetes(K8S)各种攻击方法
  • 【MySQL】内外连接
  • selenium执行出现异常,SessionNotCreatedException ChromeDriver only supports
  • Flink:快速掌握批处理数据源的创建方法
  • 基于cubeMX的正点原子miniSTM32对W25Q64的存储使用
  • C++笔记(三)
  • c语言不定参数
  • 云手机与实体手机的对比
  • diffusion 和 gan 的优缺点对比
  • VC++中使用OpenCV进行人脸检测
  • 11Docker数据持久化
  • RK3588平台开发系列讲解(视频篇)RKMedia框架
  • Vue3 Teleport 将组件传送到外层DOM位置
  • 【学网攻】 第(5)节 -- Cisco VTP的使用
  • uniapp复选框 实现排他选项
  • openssl3.2/test/certs - 004 - cross root and root cross cert