当前位置:网站首页>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 .
边栏推荐
- 【基于栈的二叉树中序遍历】二叉树的中序遍历+栈,O(h)的空间复杂度
- June translation of CET-6 in 2022
- matplotlib子图美化操作
- kubernetes集群搭建详细教程
- Lnc2meth: methylation sites on disease-related lncrna
- 如何利用MES管理系统实现防错和预警
- Argo CD usage
- flutter jpush
- Superparameters and model parameters
- Configuring the eigen3 development environment for vs2017 on win10
猜你喜欢
随机推荐
Bloom filter
Understand this point
Lnc2meth: methylation sites on disease-related lncrna
【基于栈的二叉树中序遍历】二叉树的中序遍历+栈,O(h)的空间复杂度
Data analysis part: common indicators of different industries
【input】输入框事件总结
WordPress实现左边栏显示文章目录
使用cell ranger进行单细胞转录组定量分析
From stream to kotlin to spl
远程辅助必备免费神器ToDesk远程控制软件(答辩,远程,调试,办公)必备远程工具
Yield guild games and Walken reach cooperation
152 Solana getting started (16) - create a metaplexnft
156 rust and Solana environment configuration
(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
Ztmao主题猫wordpress主题经典失传版/WP网站模板下载站源码+全局SEO功能设定
Do you know all the extension racks of ThinkPHP?
Two ideas of I2C driver implementation (I2C dev.c and I2C core.c)
天气预报小程序源码/天气类微信小程序源码
Wechat applet_ 4. Wxss template style
[flutter special topic] 72 graphic minimalist custom running lamp acemarquee yyds dry goods inventory









