1 添加依赖
xml
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls</artifactId>
<version>5.3.3</version>
</dependency>
2 代码使用
java
package cctd.controller;
import com.spire.xls.FileFormat;
import com.spire.xls.Workbook;
import java.io.*;
public class MainServer {
public static void main(String[] args) {
//加载xml文件或 Office OpenXml 类型的xsl文件
Workbook wb = new Workbook();
File file = new File("C:\\Users\\17240\\Downloads\\1.xml");
//将File转为inputstream流
InputStream is = null;
try {
is = new FileInputStream(file);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
wb.loadFromXml(is);
//转为2013版xlsx格式的Excel
wb.saveToFile("C:\\Users\\17240\\Downloads\\2.xlsx", FileFormat.Version2013);
}
}