Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

填充模板时如果模板是多个单元格合并则会丢失被覆盖的数据 #4015

Open
bzw0614 opened this issue Oct 8, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@bzw0614
Copy link

bzw0614 commented Oct 8, 2024

    public String createReportData(ReportTemplate reportTemplate,Long stationId,Long year,Long month) {
        //List<Map<String,Object>> reportFillDataMap = getReportFillData(stationId,year,month);
        List<Map<String,String>> dateList = getDayOfMonth(year,month);
        Map<String,String> nameMap = new HashMap<>();
        File file2 = new File(sysInit.getFileUploadPath() + "temp/");
        if (!file2.exists()) {
            file2.mkdirs();
        }
        //根据Excel模板生成数据报表
        String templateFilePath = sysInit.getFileUploadPath() + reportTemplate.getReportUrl();
        String fileExtension =  templateFilePath.substring(templateFilePath.lastIndexOf("."));
        String reportFilePath = "temp/" + Calendar.getInstance().getTimeInMillis() + fileExtension;
        ExcelWriter excelWriter = EasyExcel.write(sysInit.getFileUploadPath() + reportFilePath).withTemplate(templateFilePath).build();
        Workbook workbook = excelWriter.writeContext().writeWorkbookHolder().getWorkbook();
        workbook.setForceFormulaRecalculation(true);
        int sheetNum = workbook.getNumberOfSheets();
        FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.HORIZONTAL).build();
        for (int i = 0; i < sheetNum; i++) {
            WriteSheet writeSheet = EasyExcel.writerSheet(i).build();
            excelWriter.fill(dateList,fillConfig, writeSheet);
        }
        excelWriter.finish();
        return reportFilePath;
    }
@bzw0614 bzw0614 added the bug Something isn't working label Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants