he2802 1 年間 前
コミット
a41449714c

+ 60 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/utils/poi/ExcelUtil.java

@@ -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)

+ 1 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeUserServiceImpl.java

@@ -4322,7 +4322,7 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
             }
             String goodsPeriodPath = goodsDirPath + "/学时记录" + System.currentTimeMillis() + ".xlsx";
             ExcelUtil<DangAnPeriodExportAllVo> util3 = new ExcelUtil<DangAnPeriodExportAllVo>(DangAnPeriodExportAllVo.class);
-            util3.exportEasyExcelUtil(studyList, DangAnPeriodExportAllVo.class, goodsPeriodPath);
+            util3.exportEasyExcelUtilWithImg(studyList, DangAnPeriodExportAllVo.class, goodsPeriodPath);
         }
         return true;
     }