This commit is contained in:
wucongxing8150 2025-07-08 09:23:20 +08:00
parent 327698768f
commit 3fc39eeb12

View File

@ -143,7 +143,8 @@ public class CaseplatformCaseExcelController {
contentStyle.setBorderLeft(BorderStyle.THIN); contentStyle.setBorderLeft(BorderStyle.THIN);
contentStyle.setBorderRight(BorderStyle.THIN); contentStyle.setBorderRight(BorderStyle.THIN);
ExcelWriter writer = EasyExcel.write(outputStream, ExportExpertCaseExcelVo.class) // ExcelWriter writer = EasyExcel.write(outputStream, ExportExpertCaseExcelVo.class)
ExcelWriter writer = EasyExcel.write(response.getOutputStream(), ExportExpertCaseExcelVo.class)
.head(head) .head(head)
.excelType(ExcelTypeEnum.XLSX) .excelType(ExcelTypeEnum.XLSX)
.registerWriteHandler(new HorizontalCellStyleStrategy(headStyle, contentStyle)) .registerWriteHandler(new HorizontalCellStyleStrategy(headStyle, contentStyle))
@ -238,10 +239,15 @@ public class CaseplatformCaseExcelController {
totalRow.getCell(8).setCellValue(totalTax); totalRow.getCell(8).setCellValue(totalTax);
totalRow.getCell(9).setCellValue(totalTotal); totalRow.getCell(9).setCellValue(totalTotal);
// 6通知浏览器以附件的形式下载处理设置返回头要注意文件名有中文
String fileName = URLEncoder.encode("病例数据", "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
response.setContentType("multipart/form-data");
response.setCharacterEncoding("utf-8");
writer.finish(); writer.finish();
outputStream.close();
System.out.println("Excel 导出完成,路径: " + filePath); // outputStream.close();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }