From c7795eb09f3059f1a0310bc817e2fa0e9e64d29e Mon Sep 17 00:00:00 2001 From: whyclxw <810412026@qq.com> Date: 星期四, 26 六月 2025 21:15:01 +0800 Subject: [PATCH] Merge branch 'master' of http://118.89.139.230:10101/r/powerIntelligenceSystem --- src/main/java/com/whyc/service/ExportService.java | 35 +++++++++++++++++++++++++++++++++-- 1 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/whyc/service/ExportService.java b/src/main/java/com/whyc/service/ExportService.java index 3e92717..070075b 100644 --- a/src/main/java/com/whyc/service/ExportService.java +++ b/src/main/java/com/whyc/service/ExportService.java @@ -4,7 +4,7 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; import com.whyc.dto.Real.ExportTinfDataDto; -import com.whyc.dto.Response; +import com.whyc.dto.RealDataStatic.ResRealExportAc; import com.whyc.dto.Statistic.BattCompareStic; import com.whyc.dto.Statistic.MonStic; import com.whyc.dto.Statistic.SticCompare15Res; @@ -16,7 +16,6 @@ import com.whyc.util.ActionUtil; import com.whyc.util.ServletUtils; import org.apache.poi.hssf.usermodel.*; -import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.usermodel.ClientAnchor; import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.factory.annotation.Autowired; @@ -276,4 +275,36 @@ e.printStackTrace(); } } + //瀹炴椂鏁版嵁缁熻鏇茬嚎-浜ゆ祦鍗曞厓瀵煎嚭(2.5.2) + public void exportRealStaticAc(HttpServletRequest req, HttpServletResponse resp, ResRealExportAc exportAc) throws IOException { + List<String> picList=exportAc.getPicList(); + Map<String,Object> map=new HashMap<>(); + List<ImageEntity> imageList = new ArrayList<>(); + BASE64Decoder decoder = new BASE64Decoder(); + if(picList!=null&&picList.size()>0){ + for(int i=0;i<picList.size();i++){ + ImageEntity pic = new ImageEntity(); + pic.setData(decoder.decodeBuffer(picList.get(i).substring(picList.get(i).indexOf(",") + 1))); + pic.setHeight(1000); // 蹇呴』璁剧疆楂樺害 + pic.setColspan(6); + pic.setRowspan(17); + imageList.add(pic); + } + } + map.put("imageList", imageList); + //鑾峰彇瀵煎嚭妯℃澘鍦板潃 + ClassPathResource classPathResource = new ClassPathResource("excel_templates/realstic_ac_template.xls"); + String path = classPathResource.getPath(); + TemplateExportParams templateExportParams1 = new TemplateExportParams(path,true); + Workbook wb = ExcelExportUtil.exportExcel(templateExportParams1, map); + try { + String fileName = "瀹炴椂鏁版嵁缁熻鏇茬嚎-浜ゆ祦鍗曞厓.xls"; + resp.setContentType("application/vnd.ms-excel"); + resp.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "utf-8")); + resp.flushBuffer(); + wb.write(resp.getOutputStream()); + } catch (IOException e) { + e.printStackTrace(); + } + } } \ No newline at end of file -- Gitblit v1.9.1