目录
整体结构
加入依赖
在pom.xml中加入此依赖
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.1.7</version>
</dependency>
实体类
在类上面加入一下注解,可以根据自己需求修改列宽等数据。
@ColumnWidth(20) //列宽 @ContentRowHeight(20)//数据行高 @HeadRowHeight(30)//表头高 @Data @ExcelIgnoreUnannotated //解决不加ExcelProperty注解的,也会出现在excel中
在想要展现在Excel表中属性加上注解
@ExcelProperty(value = "字典名称",index = 1) //value:在excel中列名,index:次序
具体表现为下图:
package com.example.ideaworkplace.pojo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
import com.alibaba.excel.annotation.write.sty