longz
2026-07-20 7fa02f9b28991ce3189aea3629cb7a3f3fb3b122
ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/poi/ExcelUtil.java
@@ -718,7 +718,7 @@
        for (Object[] os : fields)
        {
            Excel excel = (Excel) os[1];
            String key = StringUtils.format("data_{}_{}_{}", excel.align(), excel.color(), excel.backgroundColor());
            String key = StringUtils.format("data_{}_{}_{}_{}", excel.align(), excel.color(), excel.backgroundColor(), excel.cellType());
            if (!styles.containsKey(key))
            {
                CellStyle style = wb.createCellStyle();
@@ -734,6 +734,10 @@
                style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
                style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
                style.setFillForegroundColor(excel.backgroundColor().getIndex());
                if (ColumnType.STRING == excel.cellType())
                {
                    style.setDataFormat(wb.createDataFormat().getFormat("@"));
                }
                Font dataFont = wb.createFont();
                dataFont.setFontName("Arial");
                dataFont.setFontHeightInPoints((short) 10);
@@ -756,10 +760,10 @@
        cell.setCellValue(attr.name());
        setDataValidation(attr, row, column);
        cell.setCellStyle(styles.get(StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor())));
        sheet.setDefaultColumnStyle(column, styles.get(StringUtils.format("data_{}_{}_{}_{}",
                attr.align(), attr.color(), attr.backgroundColor(), attr.cellType())));
        if (isSubList())
        {
            // 填充默认样式,防止合并单元格样式失效
            sheet.setDefaultColumnStyle(column, styles.get(StringUtils.format("data_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor())));
            if (attr.needMerge())
            {
                sheet.addMergedRegion(new CellRangeAddress(rownum - 1, rownum, column, column));
@@ -889,7 +893,8 @@
                    CellRangeAddress cellAddress = new CellRangeAddress(subMergedFirstRowNum, subMergedLastRowNum, column, column);
                    sheet.addMergedRegion(cellAddress);
                }
                cell.setCellStyle(styles.get(StringUtils.format("data_{}_{}_{}", attr.align(), attr.color(), attr.backgroundColor())));
                cell.setCellStyle(styles.get(StringUtils.format("data_{}_{}_{}_{}",
                        attr.align(), attr.color(), attr.backgroundColor(), attr.cellType())));
                // 用于读取对象中的属性
                Object value = getTargetValue(vo, field, attr);