word怎么转换成docx文件(word的docx和doc格式相互转换)
word怎么转换成docx文件(word的docx和doc格式相互转换)public File convertDocToDocx(String srcPath String descPath) { Document dc = new Document(); dc.loadFromFile(srcPath); dc.saveToFile(descPath FileFormat.Docx_2013); return new File(descPath); }srcPath可以是.doc路径也可以是.docx路径,自己试一下吧
当你调试bug的时候
1.添加依赖
pom添加
<repositories>
<repository>
<id>com.e-iceblue</id>
<url>http://repo.e-iceblue.cn/repository/maven-public/</url>
</repository>
</repositories>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.doc.free</artifactId>
<version>3.9.0</version>
</dependency>
2.构建工具类
public File convertDocToDocx(String srcPath String descPath) {
Document dc = new Document();
dc.loadFromFile(srcPath);
dc.saveToFile(descPath FileFormat.Docx_2013);
return new File(descPath);
}
srcPath可以是.doc路径也可以是.docx路径,自己试一下吧