下载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();}}