JeecgBoot 单表数据导出多sheet实例
生活随笔
收集整理的這篇文章主要介紹了
JeecgBoot 单表数据导出多sheet实例
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
現在要導出格式如下:
[外鏈圖片轉存失敗,源站可能有防盜鏈機制,建議將圖片保存下來直接上傳(img-FvUS8Uav-1615193518632)(images/sheet1.png)]
實體如下:
數據格式如下:
//多個map,對應了多個sheet List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();for(int i=0;i<3;i++){Map<String, Object> map = new HashMap<String, Object>();map.put("title",getExportParams("測試"+i));//表格titlemap.put("entity",TestEntity.class);//表格對應實體//數據封裝方式一:map數據,手動封裝ExcelExportEntity集合List<Map> ls=new ArrayList<Map> ();for(int j=0;j<10;j++){Map map = new HashMap();map1.put("name","李四"+j);map1.put("age",18+j);ls.add(map);}//數據封裝方式二:實體類List<TestEntity> ls=new ArrayList<TestEntity> ();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);總結
以上是生活随笔為你收集整理的JeecgBoot 单表数据导出多sheet实例的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: poj-1064Cable master
- 下一篇: Oracle的Endgame,或被Ama