当前位置:网站首页>Easyexcel: read Excel data into the list set
Easyexcel: read Excel data into the list set
2022-06-27 06:38:00 【YUELEI118】
1. pom.xml
Add dependency
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.1.0</version>
</dependency>
2. Defining entity classes
annotation :@ExcelProperty(" Parameters "), Parameters of the corresponding Excel Column name in , There is no order , Write whatever column you want .
public class ReportDetail {
// ExcelIgnore annotation : Entity classes need , however Excel Columns not in , there id Is the self increment of the database ID Primary key
@ExcelIgnore
private Integer id;
@ExcelProperty(" full name ")//Excel Column name in
private String personName;
.
.
// No arguments structure : must
// There are parametric structures ,get/set Method
3. Define storage Excel Secondary data list aggregate
ArrayList<ReportDetail> reportDetails = new ArrayList<>();
4. Read Excel
read Method :
The first parameter :path:Excel File path or InputStream
The second parameter : Entity class
The third parameter :ReadListener Anonymous implementation class of , Parameters in generics : Entity class type
EasyExcel.read( route , Entity class name .class, new AnalysisEventListener< Entity class name >() {
@Override
public void invoke( Entity class name Shape parameter , AnalysisContext analysisContext) {
list aggregate .add( Shape parameter );
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
}
}).sheet("Excel Table name in , Default first table ").doRead();
- Corresponding to the above entity class and list aggregate
EasyExcel.read(path, ReportDetail.class, new AnalysisEventListener<ReportDetail>() {
@Override
public void invoke(ReportDetail reportExcel, AnalysisContext analysisContext) {
// Save each read line into reportDetails Collection
reportDetails.add(reportExcel);
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
}
}).sheet().doRead();
边栏推荐
- 聊聊领域驱动设计
- 面试官:请你介绍一下缓存穿透、缓存空值、缓存雪崩、缓存击穿的,通俗易懂
- 主动学习(active learning)
- Compatibility comparison between tidb and MySQL
- NoViableAltException([email protected][2389:1: columnNameTypeOrConstraint : ( ( tableConstraint ) | ( columnNameT
- Thesis reading skills
- G1和ZGC垃圾收集器
- 观测电机转速转矩
- 427- binary tree (617. merge binary tree, 700. search in binary search tree, 98. verify binary search tree, 530. minimum absolute difference of binary search tree)
- extendible hashing
猜你喜欢

427- binary tree (617. merge binary tree, 700. search in binary search tree, 98. verify binary search tree, 530. minimum absolute difference of binary search tree)

AHB2APB桥接器设计(2)——同步桥设计的介绍

从5秒优化到1秒,系统飞起来了...

JVM garbage collection mechanism

Information System Project Manager - Chapter VII project cost management

JVM常用指令

426 binary tree (513. find the value in the lower left corner of the tree, 112. sum of paths, 106. construct a binary tree from the middle order and post order traversal sequence, 654. maximum binary

Fast realization of Bluetooth communication between MCU and mobile phone

Redis 缓存穿透、缓存击穿、缓存雪崩

面试官:你天天用 Lombok,说说它什么原理?我竟然答不上来…
随机推荐
Caldera安装及简单使用
Dev++ 环境设置C语言关键字显示颜色
Fast realization of Bluetooth communication between MCU and mobile phone
Thesis reading skills
Overview of database schema in tidb
Matlab GUI interface simulation DC motor and AC motor speed simulation
下载cuda和cudnn
The SCP command is used in the expect script. The perfect solution to the problem that the SCP command in the expect script cannot obtain the value
TiDB 数据库快速上手指南
HTAP Quick Start Guide
winow10安装Nexus nexus-3.20.1-01
multiprocessing. Detailed explanation of pool
MPC control of aircraft wingtip acceleration and control surface
Modeling competition - optical transport network modeling and value evaluation
LeetCode 0086. Separate linked list
论文阅读技巧
高斯分布Gaussian distribution、線性回歸、邏輯回歸logistics regression
面试官:用分库分表如何做到永不迁移数据和避免热点问题?
HTAP 深入探索指南
NoViableAltException([email protected][2389:1: columnNameTypeOrConstraint : ( ( tableConstraint ) | ( columnNameT