https://gitee.com/z1527050133/common-component-poi-spring-boot-starter
目前该版本支持jdk17 spring-boot3.0.4,对应项目兼容修改pom
该组件支持xls、xlsx格式导入导出,支持导出最大行数可达百万行以上(具体最大行数未测试,150万行数可导出,在104万行数据时分第二sheet页)
支持导入文件类型有 org.springframework.web.multipart.MultipartFile、java.io.File、byte数组
支持导出图片
可在excel中显示
可在excel中显示超链接,导出压缩包文件
该代码打包后,在项目pom中引用,包含图片的导出,如若遇有问题,可留言
使用方法示例
git 在本地下载好代码后使用idea打开,调整maven设置
install
在本地仓库即可看到jar包
在需要使用poi工具的项目中修改pom文件,增加dependency
<dependency>
<groupId>easy.common.component</groupId>
<artifactId>poi</artifactId>
<version>0.0.3</version>
</dependency>
代码使用示例:
导出
MassiveExcel.export(exportDTOs, response, "xxx.xlsx");
MassiveExcel.export(exportDTOs, response, "xxx.xls");
@Data
@Title(value = "报表导出",exportType = ExportTpye.ZIP)
public class ExportDTO {
/**
* id
*/
@ExcelTag(value = "id")
private String id;
/**
* 图片
*/
@ExcelTag(value = "图片",valueType = ValueType.PIC)
private PicData pic;
}
导入(OutDTO代指具体对象)
MassiveExcel.excelFileToObject(excelFile,OutDTO.class);
@Data
@Title(exportType = ExportTpye.EXCEL)
public class OutDTO {
@ExcelTag(value = "字段名")
private String alarmNo;
}