1. 引入easyExcel的maven地址
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.3</version>
</dependency>
2. 建立导出用到的数据实体类
package com.excel.excel.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@ContentRowHeight(17) //文本行高度
@HeadRowHeight(20) //标题高度
@ColumnWidth(20)//行宽
@Data
public class User {
@ExcelProperty(value = "用户姓名", index = 0)
private String userName;
@ExcelProperty(value = "密码", index = 1)
private String password;
@ExcelProperty(value = 电话号码", index = 2)
private String telephone;
@ExcelProperty(value = 创建日期", index = 3)