Gradle
implementation group: ‘com.alibaba’, name: ‘easyexcel’, version: ‘2.2.6’
Maven
com.alibaba
easyexcel
2.2.6
//保存路径与名字
private final static String fileName = “E:\” + System.currentTimeMillis() + “.xlsx”;
@Test
// public static void easyUtil(List heads,String head,List<Map<String, Object>> list){
public void easyUtil(){
List heads = new ArrayList<>(); //表头信息
heads.add(“银行名称”);
heads.add(“期间新增项目”);
heads.add(“期间新增担保总额”);
heads.add(“期间新增解保项目数”);
heads.add(“期间新增解保金额”);
heads.add(“在保项目数”);
heads.add(“在保余额”);
heads.add(“银行利率”);
String head=“惠农通数据表”; //主表头
List<Map<String, Object>> list = new ArrayList<>();
Map<String,Object> test = new LinkedHashMap<>(); //手动添加测试数据(可根据需要从数据库查询)
test.put(“t1”, 1);
test.put(“t2”, 2);
test.put(“t3”, 3);
test.put(“t4”, 4);
test.put(“t5”, 5);
test.put(“t6”, 6);
test.put(“t7”, 7);
test.put(“t8”, 8);
list.add(test);
Map<String,Object> test2 = new LinkedHashMap<>();
test.put(“t1”, 1);
test.put(“t2”, 2);
test.put(“t3”, 3);
test.put(“t4”, 4);
test.put(“t5”, 5);
test.put(“t6”, 6);
test.put(“t7”, 7);
test.put(“t8”, 8);
list.add(test2);
List objects = new ArrayList<>();
List<List> hs = new ArrayList<>();
for (String s : heads) {
hs.add(Arrays.asList(head,s));
}
// List<Map<String, Object>> l = new ArrayList<>();
Collection values;
List<List> list2 = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
values = list.get(i).values();
for (Object value : values) {
objects.add(value.toString());
}
list2.add(objects);
}
EasyExcel.write(fileName).head(hs).sheet(“模板”).doWrite(list2);
System.out.println(“导出成功”);
}
//保存路径与名字(也可以放进工具类,通过参数传递)
private final static String fileName = “E:\” + System.currentTimeMillis() + “.xlsx”;
/**
-
简易版动态导出
-
@param heads 表头
-
@param head 主表头
-
@param list 表数据
*/
@Test
public static void easyUtil(List heads,String head,List<Map<String, Object>> list){
// public void easyUtil(){
List objects = new ArrayList<>();
List<List> hs = new ArrayList<>();
for (String s : heads) {
hs.add(Arrays.asList(head,s));
}
// List<Map<String, Object>> l = new ArrayList<>();
Collection values;
List<List> list2 = new ArrayList<>();
for (int i = 0; i < list.size(); i++) {
values = list.get(i).values();
for (Object value : values) {
objects.add(value.toString());
}
list2.add(objects);
}
EasyExcel.write(fileName).head(hs).sheet(“模板(sheet名字)”).doWrite(list2);
System.out.println(“导出成功”);
}
============================================================================
package excel;
import com.alibaba.excel.EasyExcel;
import java.util.*;
总结
谈到面试,其实说白了就是刷题刷题刷题,天天作死的刷。。。。。
为了准备这个“金三银四”的春招,狂刷一个月的题,狂补超多的漏洞知识,像这次美团面试问的算法、数据库、Redis、设计模式等这些题目都是我刷到过的
并且我也将自己刷的题全部整理成了PDF或者Word文档(含详细答案解析)
66个Java面试知识点
架构专题(MySQL,Java,Redis,线程,并发,设计模式,Nginx,Linux,框架,微服务等)+大厂面试题详解(百度,阿里,腾讯,华为,迅雷,网易,中兴,北京中软等)
算法刷题(PDF)
了PDF或者Word文档(含详细答案解析)**
[外链图片转存中…(img-XrTGNUSZ-1714340480486)]
66个Java面试知识点
架构专题(MySQL,Java,Redis,线程,并发,设计模式,Nginx,Linux,框架,微服务等)+大厂面试题详解(百度,阿里,腾讯,华为,迅雷,网易,中兴,北京中软等)
[外链图片转存中…(img-QoUY9i1i-1714340480487)]
算法刷题(PDF)
[外链图片转存中…(img-Jppnc55y-1714340480487)]