当前位置:网站首页>Easyexcel introduction-01
Easyexcel introduction-01
2022-06-21 07:04:00 【Sister min】
EasyExcel- brief introduction
brief introduction
Java analysis 、 Generate Excel Well known frameworks are
Apache poi、jxl. But they all have a serious problem that is very memory consuming ,poiThere is a set SAX Mode API It can solve some memory overflow problems to a certain extent , butPOIThere are still some flaws , such as 07 edition Excel Decompression and storage after decompression are done in memory , Memory consumption is still high .easyexcelRewrotepoiYes 07 edition Excel Parsing , One 3M Of excel usePOI saxParsing still needs 100M Left and right memory , change to the use of sth.easyexcelIt can be reduced to a few M, And the biggerexcelThere will be no memory overflow ;03 Version depends on POI Of sax Pattern , In the upper layer, the encapsulation of model transformation is done , Make the user more simple and convenient
Project structures,
Import dependence
<!--easyExcel Dependency import -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.3</version>
</dependency>
Write test entity classes
package entry;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/** * Created by jdx on 2022/6/17 In the morning 12:10 */
/* Equivalent to... In entity class get set Method */
@Data
/* Equivalent to a parametric structure */
@AllArgsConstructor
/* Equivalent to nonparametric construction */
@NoArgsConstructor
public class Student {
/*@ExcelProperty * 1、 Details are equivalent to the header definition * 2、 Entity alias * */
@ExcelProperty(" full name ")
private String name;
@ExcelProperty(" Admission time ")
private String admissionATime;
@ExcelProperty(" Gender ")
private Boolean sex;
@ExcelProperty(" Contact information ")
private String contactDetails;
@ExcelProperty(" class ")
private String className;
@ExcelProperty(" achievement ")
private String score;
@ExcelProperty(" mailbox ")
private String e_mail;
}
Writing test classes
package test;
import com.alibaba.excel.EasyExcel;
import org.junit.Test;
import entry.Student;
import java.util.ArrayList;
/** * Created by jdx on 2022/6/17 In the morning 12:13 */
public class test {
@Test
public static void main(String[] args) {
/* Create a new... To store the output stream object list*/
ArrayList<Student> students = new ArrayList<Student>();
/* Create a new one Student object */
Student student01 = new Student(" Miyamoto musashi ","2016-03",true,"12345678911"," Class 11, grade 9 ","A","[email protected]");
Student student02 = new Student(" Nacoro ","2016-03",false,"12345678912"," Class 11, grade 9 ","A","[email protected]");
Student student03 = new Student(" I don't know sun ","2016-03",false,"12345678913"," Class 11, grade 9 ","A","[email protected]");
Student student04 = new Student(" Orange right Beijing ","2016-03",true,"12345678914"," Class 11, grade 9 ","A","[email protected]");
Student student05 = new Student(" The Monkey King ","2016-03",true,"12345678915"," Class 11, grade 9 ","A","[email protected]");
Student student06 = new Student(" Master Sanzang ","2016-03",true,"12345678916"," Class 11, grade 9 ","A","[email protected]");
Student student07 = new Student(" Pig eight quit ","2016-03",true,"12345678917"," Class 11, grade 9 ","A","[email protected]");
Student student08 = new Student(" Yao ","2016-03",true,"12345678918"," Class 11, grade 9 ","A","[email protected]");
Student student09 = new Student(" Li Xiaoyao ","2016-03",true,"12345678919"," Class 11, grade 9 ","A","[email protected]");
Student student10 = new Student(" Zhaoliner ","2016-03",false,"12345678910"," Class 11, grade 9 ","A","[email protected]");
Student student11 = new Student(" Li Bai a","2016-03",true,"12345678922"," Class 11, grade 9 ","A","[email protected]");
/* Add data */
students.add(student01);
students.add(student02);
students.add(student03);
students.add(student04);
students.add(student05);
students.add(student06);
students.add(student07);
students.add(student08);
students.add(student09);
students.add(student10);
students.add(student11);
/* Define file name */
String fileName = " On the school roster .xlsx";
/* Test output mode * 1、.write Method parameter * File name * Construction object * 2、.sheet Method parameter * sheet name * 3、.doWrite Method * Incoming and output stream objects */
EasyExcel.write(fileName,Student.class).sheet("ceshi").doWrite(students);
}
}
test result

So far, the project has been successfully built and simple tests have been carried out .
边栏推荐
- kubernetes集群搭建详细教程
- @nonnull annotation of Lombok
- MySQL MHA
- Modbus poll v9.9.2 build 1690 MODBUS test tool single file version
- 微信小程序_4,WXSS模板样式
- Understanding generics mechanism
- Product manager proficient in Axure tools
- 远程辅助必备免费神器ToDesk远程控制软件(答辩,远程,调试,办公)必备远程工具
- Use the loupe cell browser to view the results of 10x single cell transcriptome analysis
- Google Earth engine (GEE) - US native lithology data set
猜你喜欢

Wechat applet_ 3. Wxml template syntax

Use the loupe cell browser to view the results of 10x single cell transcriptome analysis

如何利用MES管理系统实现防错和预警
![[transfer] liurun: don't discuss business with people without logic](/img/e7/7881a9f02c7773f92702f6b0232125.png)
[transfer] liurun: don't discuss business with people without logic

matplotlib子图美化操作

海明码校验【简单详细】

微信小程序_5,全局配置

Lnc2Meth:与疾病相关的lncRNA上的甲基化位点

Understanding generics mechanism

IDM mobile terminal function upgrade description
随机推荐
集线器、交换机、路由器
Candy tunnel JS special effect code
(programming exercises of various regular numbers) the prime number in the output range, the factorization prime factor of an integer, the maximum common divisor and minimum common multiple of two num
Understand this point
Butler-Volmer 公式的由来
数据库与缓存数据一致性问题
C language program design - Sanzi chess (semester homework)
产品经理精通Axure工具篇
Minesweeping - C language - Advanced (recursive automatic expansion + chess mark)
ADEX governance voting: pledge reward halved
Filtre Bloom
[mapbox] Basics
x86 CPU访问DRAM和PCI
Geo2r: difference analysis of data in geo database
Grid search method
Use the loupe cell browser to view the results of 10x single cell transcriptome analysis
Building a hard core Gateway - resume
Onnx to tensorrt learning notes
Quantitative analysis of single cell transcriptome using cell Ranger
[middle order traversal of binary tree based on stack] middle order traversal of binary tree + stack, spatial complexity of O (H)