|
@@ -709,6 +709,66 @@ public class ExcelUtil<T>
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public void exportEasyExcelUtilWithImg(List<T> list,Class<T> clazz,String path)
|
|
|
|
|
+ {
|
|
|
|
|
+ OutputStream out = null;
|
|
|
|
|
+ // Workbook workbook = null;
|
|
|
|
|
+ ExportParams deptExportParams = new ExportParams();
|
|
|
|
|
+ // 设置sheet得名称
|
|
|
|
|
+ deptExportParams.setSheetName("表1");
|
|
|
|
|
+ String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
|
|
+ Map<String, Object> deptExportMap = new HashMap<>();
|
|
|
|
|
+ deptExportMap.put("title", deptExportParams);
|
|
|
|
|
+ deptExportMap.put("entity", clazz);
|
|
|
|
|
+ // sheet中要填充得数据
|
|
|
|
|
+ deptExportMap.put("data", list);
|
|
|
|
|
+ List<Map<String, Object>> sheetsList = new ArrayList<>();
|
|
|
|
|
+ sheetsList.add(deptExportMap);
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(sheetsList, ExcelType.HSSF);
|
|
|
|
|
+ File desc = new File(path);
|
|
|
|
|
+ if (!desc.getParentFile().exists())
|
|
|
|
|
+ {
|
|
|
|
|
+ desc.getParentFile().mkdirs();
|
|
|
|
|
+ }
|
|
|
|
|
+ out = new FileOutputStream(path);
|
|
|
|
|
+ workbook.write(out);
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (Exception e)
|
|
|
|
|
+ {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ log.error("导出Excel异常{}", e.getMessage());
|
|
|
|
|
+ throw new CustomException("导出Excel失败,请联系网站管理员!");
|
|
|
|
|
+ }
|
|
|
|
|
+ finally
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
|
|
+ if (wb != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ wb.close();
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (IOException e1)
|
|
|
|
|
+ {
|
|
|
|
|
+ e1.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (out != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ out.close();
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (IOException e1)
|
|
|
|
|
+ {
|
|
|
|
|
+ e1.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
public void exportEasyExcelStudy(List<Map<String, Object>> sheetsList,String path)
|
|
public void exportEasyExcelStudy(List<Map<String, Object>> sheetsList,String path)
|