Now to export the format as follows:
The entities are as follows:
Public class TestEntity{@excel (name = "name ", width = 15) private String username; @excel (name = "Age ", width = 15) private int age; . Omit the subsequent getSet
The data format is as follows:
Sheet List<Map<String, Object>> ListMap = new ArrayList<Map<String, Object> bb3 (); for(int i=0; i<3; i++){ Map<String, Object> map = new HashMap<String, Object>(); The map. The put (" title ", getExportParams (" test "+ I)); // table title map.put("entity", testEntity. Class); ArrayList<Map> (); ArrayList<Map> (); ArrayList<Map> (); ArrayList<Map> (); for(int j=0; j<10; j++){ Map map = new HashMap(); Map1. Put (" name ", "li si" + 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. Elegantly-named setName (" * * "+ j); testEntity.setAge(18+j); ls.add(testEntity); } map.put("data", ls); listMap.add(map); } public static ExportParams getExportParams(String Name) {// ExportParams public static ExportParams getExportParams(String Name) ExportParams(name,name,ExcelType.XSSF); }
Call ExcelExportUtil exportExcel method to generate workbook
Workbook wb = ExcelExportUtil.exportExcel(listMap,ExcelType.XSSF);