文件操作:Xml转Excel
1 添加依赖
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.xls</artifactId>
<version>5.3.3</version>
</dependency>
2 代码使用
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);
}
}
3 实现效果
原文地址:https://blog.csdn.net/weixin_44174685/article/details/143503291
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!