- 引入依赖:在项目的
pom.xml
文件中添加easyexcel
的依赖,例如:<dependency> <groupId>com.alibaba</groupId> <artifactId>easyexcel</artifactId> <version>3.1.1</version> </dependency>
- 定义实体类:创建一个实体类,用于映射 Excel 表格中的数据。在实体类的字段上添加相关注解,例如:
@Data @ApiModel(value = "exportEntity", description = "exportEntity") public class ExportEntity { /** id */ @ApiModelProperty(value = "id") @ExcelProperty("id") private long id; /** 名称 */ @ApiModelProperty(value = "名称") @ExcelProperty("名称") private String name; /** 年龄 */ @ApiModelProperty(value = "年龄") @ExcelProperty("年龄") private int age; /** 性别,使用@ExcelIgnore注解会忽略该字段 */ @ApiMod
easyexcel进行导出
最新推荐文章于 2024-09-29 08:33:21 发布