fei
2 天以前 5de5db24efe1b25896c37f395124a207584bcb38
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java
@@ -276,8 +276,8 @@
     */
    public void exportExcelManySheet(HttpServletResponse response, List<ExcelExp> list, boolean includeQrCode, byte[] bt,
                                     List<String> sigArr, List<String> arrAn, String inquiryNumber, String caseTitle) throws IOException {
      //  response.setContentType("application/vnd.ms-excel");
      //  response.setCharacterEncoding("utf-8");
        //  response.setContentType("application/vnd.ms-excel");
        //  response.setCharacterEncoding("utf-8");
        try {
            createWorkbook();
@@ -299,7 +299,7 @@
                    // 创建行并设置高度
                     row = sheet.createRow(firow);
                    row = sheet.createRow(firow);
                    row.setHeight((short)(40 * 40));
                    //生成二维码
                    if(includeQrCode)
@@ -345,7 +345,7 @@
                        firow = firow + 1;
                        row = sheet.createRow(firow);
                    }
                  //  sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 7));
                    //  sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 7));
                    if(firow==1)
                    {
                        sheet.addMergedRegion(new CellRangeAddress(firow, firow, 0, 8));
@@ -364,7 +364,7 @@
                    titleCell.setCellStyle(style);
                    firow = firow + 1;
                    row = sheet.createRow(firow);
               //
                    //
                    row.createCell(0).setCellValue("发文号:");
                    sheet.addMergedRegion(new CellRangeAddress(firow, firow, 1, 3));
                    row.createCell(1).setCellValue(inquiryNumber);
@@ -383,7 +383,7 @@
                    column = 0;
                } else {
                    // 普通sheet处理
                 //   recordId = (DocumentMaterialsVo)list.get(0)
                    //   recordId = (DocumentMaterialsVo)list.get(0)
                    row = sheet.createRow(0);
                    column = 0;
                }
@@ -554,21 +554,35 @@
        style.setFont(dataFont);
        styles.put("data", style);
        style = wb.createCellStyle();
        style.cloneStyleFrom(styles.get("data"));
        style.setAlignment(HorizontalAlignment.CENTER);
        style.setVerticalAlignment(VerticalAlignment.CENTER);
        // 设置单元格内容自动换行
        style.setWrapText(true);
        style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
        style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
        Font headerFont = wb.createFont();
        headerFont.setFontName("Arial");
        headerFont.setFontHeightInPoints((short) 10);
        headerFont.setBold(true);
        headerFont.setColor(IndexedColors.WHITE.getIndex());
        style.setFont(headerFont);
        styles.put("header", style);
        // 创建表头样式映射,根据Excel注解动态生成
        Map<String, CellStyle> headerStyles = new HashMap<String, CellStyle>();
        for (Object[] os : fields)
        {
            Excel excel = (Excel) os[1];
            String key = StringUtils.format("header_{}_{}", excel.headerColor(), excel.headerBackgroundColor());
            if (!headerStyles.containsKey(key))
            {
                style = wb.createCellStyle();
                style.cloneStyleFrom(styles.get("data"));
                style.setAlignment(HorizontalAlignment.CENTER);
                style.setVerticalAlignment(VerticalAlignment.CENTER);
                // 设置单元格内容自动换行
                style.setWrapText(true);
                // 根据注解设置表头背景色 - 已注释,表头不显示背景色
                /*if (excel.headerBackgroundColor() != IndexedColors.WHITE) {
                    style.setFillForegroundColor(excel.headerBackgroundColor().index);
                    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
                }*/
                Font headerFont = wb.createFont();
                headerFont.setFontName("Arial");
                headerFont.setFontHeightInPoints((short) 10);
                headerFont.setBold(false);
                headerFont.setColor(excel.headerColor().index);
                style.setFont(headerFont);
                headerStyles.put(key, style);
            }
        }
        styles.putAll(headerStyles);
        style = wb.createCellStyle();
        style.setAlignment(HorizontalAlignment.CENTER);
@@ -614,7 +628,9 @@
        // 写入列信息
        cell.setCellValue(attr.name());
        setDataValidation(attr, row, column);
        cell.setCellStyle(styles.get("header"));
        // 根据Excel注解动态选择表头样式
        String key = StringUtils.format("header_{}_{}", attr.headerColor(), attr.headerBackgroundColor());
        cell.setCellStyle(styles.get(key));
        return cell;
    }
@@ -673,7 +689,7 @@
            sheet.setColumnWidth(column, 6000);
        } else {
            // 设置列宽
            sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 200));
            sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256));
        }
        // 如果设置了提示信息则鼠标放上去提示.
        if (StringUtils.isNotEmpty(attr.prompt())) {
@@ -1044,4 +1060,4 @@
        }
        return val;
    }
}
}