一般Excel不需要复杂的数据格式导出,只是在表头上略有区别,下面展示单行和多行表头Excel导出
1、单行表头
例如:Excel表头只有单行,那就只需要使用注解@ExcelProperty即可实现
① 添加依赖
首先,在 pom.xml 中添加 EasyExcel 的依赖:
<!-- EasyExcel 依赖 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.3.3</version>
</dependency>
② 定义数据模型
在数据模型 EnergyTimeDetailVO需要导出的字段上添加注解信息@ExcelProperty
@Data
public class EnergyTimeDetailVO {
@ApiModelProperty("时间")
@ExcelProperty(value = "时间", index = 0)
private String time;
@ApiModelProperty("起始读数")
@ExcelProperty(value = "起始