一、前言
最近在使用ruoyi框架,但是发现它自带的exportExcel功能不够方便,遂使用alibaba的easyExcel包。
首先我们先来看看ruoyi自带的exportExcel功能:
我们可以看看导出结果:
其实还是挺好看的是吧,但如果我们想添加合并单元格的功能就有点不方便了。
二、导入依赖
我们首先在ruoyi-common模块导入easyExcel的依赖包
<!-- easyexcel -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.3.2</version>
<exclusions>
</exclusions>
</dependency>
三、修改实体类
ruoyi框架的实体类需要在导出的字段上添加@Excel
注解:
public class SysPost extends BaseEntity
{
private static final long serialVersionUID = 1L;
@Excel(name = "岗位序号", cellType = ColumnType.NUMERIC)
private Long postId;
@Excel(name = "岗位编码")
private String postCode;
@Excel(name = "岗位名称")
private String postName;
@Excel(name = "岗位排序", cellType = ColumnType.NUMERIC)
private String postSort;
@Excel(name = "状态", readConverterExp = "0=正常,1=停用")
private String status;
private boolean flag <