This commit is contained in:
wwb 2026-01-06 10:09:01 +08:00
parent d3b8a38f99
commit c7a1eaca9d
2 changed files with 4 additions and 3 deletions

View File

@ -223,12 +223,13 @@ public class StatementAccountController {
// 如果填充list的对象是map,必须包涵所有list的key,哪怕数据为null必须使用map.put(key,null)
//docker生成路径
//URL templateFileUrl = ResourceUtil.getResource("templates/dzd_excel_templates.xlsx");
org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:templates/dzd_excel_templates.xlsx"); // 例如获取index.html
String templateFileUrl = resource.getURI().toString();
// org.springframework.core.io.Resource resource = resourceLoader.getResource("classpath:templates/dzd_excel_templates.xlsx"); // 例如获取index.html
// String templateFileUrl = resource.getURI().toString();
InputStream resourceAsStream = this.getClass().getResourceAsStream("templates/dzd_excel_templates.xlsx");
String pathUrl = System.getProperty("user.dir") + "/pdffile";
String fileName = pathUrl+"/对账单-"+customer.getName()+"-"+DateUtil.date(statementAccount.getDate().toLocalDate()).toString("YYYYMM")+".xlsx";
try (ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(templateFileUrl).build()) {
try (ExcelWriter excelWriter = EasyExcel.write(fileName).withTemplate(resourceAsStream).build()) {
WriteSheet writeSheet = EasyExcel.writerSheet().build();
// 直接写入数据
excelWriter.fill(models, writeSheet);