Browse Source

导出运营数据 网格

release
jianjun 3 years ago
parent
commit
d50e63628d
  1. 10
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java
  2. 9
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java

10
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ExcelUtils.java

@ -132,14 +132,20 @@ public class ExcelUtils {
return response.getOutputStream(); return response.getOutputStream();
} }
/**
* desc:easypoi导出多个sheet
* @param fileName
* @param list
* @param response
* @throws Exception
*/
public static void exportMultiSheetExcel(String fileName, List<ExportMultiView> list, HttpServletResponse response) throws Exception { public static void exportMultiSheetExcel(String fileName, List<ExportMultiView> list, HttpServletResponse response) throws Exception {
List<Map<String,Object>> excel = new ArrayList<>(); List<Map<String,Object>> excel = new ArrayList<>();
for(ExportMultiView view :list){ for(ExportMultiView view :list){
Map<String,Object> sheet = new HashMap<>(); Map<String,Object> sheet = new HashMap<>();
sheet.put("title",view.getExportParams()); sheet.put("title",view.getExportParams());
sheet.put("entity",view.getCls()); sheet.put("entity",view.getCls());
List<?> dataList = view.getDataList(); sheet.put("data", view.getDataList());
sheet.put("data", dataList);
excel.add(sheet); excel.add(sheet);
} }
Workbook workbook = ExcelExportUtil.exportExcel(excel, ExcelType.XSSF); Workbook workbook = ExcelExportUtil.exportExcel(excel, ExcelType.XSSF);

9
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/excel/ExportMultiView.java

@ -16,8 +16,17 @@ import java.util.List;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public class ExportMultiView { public class ExportMultiView {
/**
* 导出的参数 比如设置表头
*/
private ExportParams exportParams; private ExportParams exportParams;
/**
* 要导出的数据列
*/
private List<?> dataList; private List<?> dataList;
/**
* excel对应的类
*/
private Class<?> cls; private Class<?> cls;
} }

Loading…
Cancel
Save