1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 使用spire.doc实现word文档合并

使用spire.doc实现word文档合并

时间:2022-01-24 01:15:37

相关推荐

使用spire.doc实现word文档合并

下载jar包:

http://repo.e-/nexus/content/groups/public/e-iceblue/spire.doc/

maven配置:

在这里插入代码片<repositories><repository><id>com.e-iceblue</id><name>e-iceblue</name><url>http://repo.e-/nexus/content/groups/public/</url></repository></repositories><dependency><groupId> e-iceblue </groupId><artifactId>spire.doc</artifactId><version>3.2.3</version></dependency><dependency><groupId>e-iceblue</groupId><artifactId>spire.doc.free</artifactId><version>2.7.3</version></dependency>

java代码:

在这里插入代码片/*** 合并doc* @param fileList文件路径* @param newFilePath合并后新文件路径* @throws Exception*/public static void mergeDoc(List<String> fileList, String newFilePath) throws Exception {try{Document document = new Document();//创建空白页(可不创建,用Document document = new Document("文件路径"))document.createMinialDocument();//合并文档for(String path : fileList){document.insertTextFromFile(path, FileFormat.Docx_);}//保存文档document.saveToFile(newFilePath, FileFormat.Docx_);}catch(Exception e){e.printStackTrace();}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。