# easyExcel-tool **Repository Path**: xu0129/easy-excel-tool ## Basic Information - **Project Name**: easyExcel-tool - **Description**: 使用easyExcel进行大数据量导出导入,减少内存使用,避免出现oom - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 9 - **Forks**: 2 - **Created**: 2024-02-02 - **Last Updated**: 2025-04-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # easyExcel-tool #### 介绍 使用easyExcel进行大数据量导出导入,减少内存使用,避免出现oom #### 软件架构 软件架构说明 #### 安装教程 #创建表EMP雇员 CREATE TABLE emp (empno MEDIUMINT UNSIGNED NOT NULL DEFAULT 0, /*编号*/ ename VARCHAR(20) NOT NULL DEFAULT "", /*名字*/ job VARCHAR(9) NOT NULL DEFAULT "",/*工作*/ mgr MEDIUMINT UNSIGNED NOT NULL DEFAULT 0,/*上级编号*/ hiredate DATE NOT NULL,/*入职时间*/ sal DECIMAL(7,2) NOT NULL,/*薪水*/ comm DECIMAL(7,2) NOT NULL,/*红利*/ deptno MEDIUMINT UNSIGNED NOT NULL DEFAULT 0 /*部门编号*/ ) ; delimiter $$ #创建一个函数,名字 rand_string,可以随机返回我指定的个数字符串 create function rand_string(n INT) returns varchar(255) #该函数会返回一个字符串 DETERMINISTIC begin #定义了一个变量 chars_str, 类型 varchar(100) #默认给 chars_str 初始值 'abcdefghijklmnopqrstuvwxyzABCDEFJHIJKLMNOPQRSTUVWXYZ' declare chars_str varchar(100) default 'abcdefghijklmnopqrstuvwxyzABCDEFJHIJKLMNOPQRSTUVWXYZ'; declare return_str varchar(255) default ''; declare i int default 0; while i < n do # concat 函数 : 连接函数mysql函数 set return_str =concat(return_str,substring(chars_str,floor(1+rand()*52),1)); set i = i + 1; end while; return return_str; end $$ #这里我们又自定了一个函数,返回一个随机的部门号 create function rand_num( ) returns int(5) DETERMINISTIC begin declare i int default 0; set i = floor(10+rand()*500); return i; end $$ #创建一个存储过程, 可以添加雇员 create procedure insert_emp(in start int(10),in max_num int(10)) begin DETERMINISTIC declare i int default 0; #set autocommit =0 把autocommit设置成0 #autocommit = 0 含义: 不要自动提交 set autocommit = 0; #默认不提交sql语句 repeat set i = i + 1; #通过前面写的函数随机产生字符串和部门编号,然后加入到emp表 insert into emp values ((start+i) ,rand_string(6),'SALESMAN',0001,curdate(),2000,400,rand_num()); until i = max_num end repeat; #commit整体提交所有sql语句,提高效率 commit; end $$ #添加8000000数据 call insert_emp(100001,8000000)$$ #命令结束符,再重新设置为; delimiter ; 1. springboot 2. easyExcel 3. mybtisPlus #### 使用说明 根据这个博客:https://blog.csdn.net/houxian1103/article/details/132380410说明的很清楚 说明: 不能一次性查询出全部数据,我们可以分批进行查询。 针对3: 可以将300w条数据写到不同的Sheet中,每一个Sheet写一百万即可。 针对4: 不能一行一行的写入到Excel上,我们可以将分批查询的数据分批写入到Excel中。 针对5: 导入到DB时我们可以将Excel中读取的数据存储到集合中,到了一定数量,直接批量插入到DB中。 针对6: 我这里使用的mybtis插入,我的建议使用jdbc插入 1.导出 ![img_1.png](img_1.png) 2.读取xlxs文件,插入数据库 ![img.png](img.png) #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)