jeecgboot多表查询,JeecgBoot 单表数据导出多sheet实例

现在要导出格式如下:

03701d697f8827266c45860118b0670c.png

实体如下:

public class TestEntity{

@Excel(name = "姓名", width = 15)

private String username;

@Excel(name = "年龄", width = 15)

private int age;

.....省略后续getset

数据格式如下:

//多个map,对应了多个sheet

List> listMap = new ArrayList>();

for(int i=0;i<3;i++){

Map map = new HashMap();

map.put("title",getExportParams("测试"+i));//表格title

map.put("entity",TestEntity.class);//表格对应实体

//数据封装方式一:map数据,手动封装ExcelExportEntity集合

List ls=new ArrayList ();

for(int j=0;j<10;j++){

Map map = new HashMap();

map1.put("name","李四"+j);

map1.put("age",18+j);

ls.add(map);

}

//数据封装方式二:实体类

List ls=new ArrayList ();

for(int j=0;j<10;j++){

TestEntity testEntity = new TestEntity();

testEntity.setName("张三"+j);

testEntity.setAge(18+j);

ls.add(testEntity);

}

map.put("data", ls);

listMap.add(map);

}

//导出参数

public static ExportParams getExportParams(String name) {

//表格名称,sheet名称,导出版本

return new ExportParams(name,name,ExcelType.XSSF);

}

调用ExcelExportUtil.exportExcel方法生成workbook

Workbook wb = ExcelExportUtil.exportExcel(listMap,ExcelType.XSSF);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值