fei
2026-01-07 4281f6c90e4a17845a5721ab51b3bc5c5409ab45
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java
@@ -323,7 +323,7 @@
                    // 其他打印设置
                    printSetup.setPaperSize(PrintSetup.A4_PAPERSIZE);  // A4纸
                    printSetup.setLandscape(false);  // 纵向打印
                    printSetup.setLandscape(true);  // 纵向打印
                    // 创建行并设置高度
@@ -331,7 +331,7 @@
                    //生成二维码
                    if(includeQrCode)
                    {
                        row.setHeight((short)(40 * 40));
                        row.setHeight((short)(55.8 * 20));
                        Cell cell = row.createCell(6);
                        // 设置图片大小和位置
@@ -348,7 +348,7 @@
//                    anchor.setDy2(255); // 高度
                        anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
                        // 计算居中位置
                        int col1 = 3; // 中间列
                        int col1 = 4; // 中间列
                        int col2 = col1 + 3;
                        anchor.setCol1(col1);
                        anchor.setCol2(col2);
@@ -377,14 +377,14 @@
                        row = sheet.createRow(firow);
                    }
                    else
                        row.setHeight((short)(20 * 20));
                        row.setHeight((short)(33 * 20));
                    //  sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 7));
                    if(firow==1)
                    {
                        sheet.addMergedRegion(new CellRangeAddress(firow, firow, 0, 8));
                        // 创建行并设置高度
                        row.setHeight((short)(20 * 20));
                        row.setHeight((short)(33 * 20));
                    }
                    Cell titleCell = row.createCell(0);
                    titleCell.setCellValue("文件材料移交目录清单(卷内级)");
@@ -392,62 +392,86 @@
                    CellStyle style = wb.createCellStyle();
                    Font font = wb.createFont();
                    font.setBold(true);
                    font.setFontHeightInPoints((short) 18);
                    font.setFontName("宋体");
                    style.setFont(font);
                    style.setVerticalAlignment(VerticalAlignment.CENTER);
                    style.setAlignment(HorizontalAlignment.CENTER);
                    titleCell.setCellStyle(style);
                    firow = firow + 1;
                    row = sheet.createRow(firow);
                    // 将固定行高改为自动行高,以便内容能完整显示在合并区域
                    row.setHeight((short)(50*20));
                    row.setHeight((short)(27.6*20));
                    //
                    CellStyle style1 = wb.createCellStyle();
                    style1.setAlignment(HorizontalAlignment.LEFT);
                    style1.setAlignment(HorizontalAlignment.RIGHT);
                    style1.setVerticalAlignment(VerticalAlignment.TOP);
                    Font font1 = wb.createFont();
                    font1.setBold(true);
                    font1.setFontHeightInPoints((short) 12);
                    font1.setFontName("宋体");
                    style1.setFont(font1);
                    Cell cell2 = row.createCell(0);
                    cell2.setCellValue("发文号:");
                    cell2.setCellStyle(style1);
                    // 合并第1-3列
                    int startCol1 = 1;
                    int endCol1 = 3;
                    int endCol1 = 2;
                    sheet.addMergedRegion(new CellRangeAddress(firow, firow, startCol1, endCol1));
                    // 设置所有合并单元格的样式
                    for (int col = startCol1; col <= endCol1; col++) {
                        Cell mergedCell = row.createCell(col);
                        mergedCell.setCellStyle(style1);
                    }
                    // 只在起始单元格设置数据
                    CellStyle style2 = wb.createCellStyle();
                    style2.setAlignment(HorizontalAlignment.LEFT);
                    style2.setVerticalAlignment(VerticalAlignment.TOP);
                    Font font2 = wb.createFont();
                    font2.setFontHeightInPoints((short) 11);
                    font2.setFontName("宋体");
                    style2.setFont(font2);
                    Cell inquiryCell = row.getCell(startCol1);
                    inquiryCell.setCellStyle(style2);
                    inquiryCell.setCellValue(inquiryNumber);
                    Cell cell1 = row.createCell(4);
                    Cell cell1 = row.createCell(3);
                    cell1.setCellValue("案卷题名:");
                    cell1.setCellStyle(style1);
                    // 创建一个新的样式用于案卷题名合并单元格
                    CellStyle mergedCellStyle = wb.createCellStyle();
                    mergedCellStyle.cloneStyleFrom(style1); // 继承原有样式
                    mergedCellStyle.setAlignment(HorizontalAlignment.LEFT); // 改为左对齐
                    mergedCellStyle.setWrapText(true); // 启用自动换行
                    //mergedCellStyle.setVerticalAlignment(VerticalAlignment.CENTER); // 垂直居中
                    // 合并第5-8列
                    int startCol = 5;
                    int startCol = 4;
                    int endCol = 8;
                    // 先创建所有需要的单元格并设置样式
                    for (int col = startCol; col <= endCol; col++) {
                        Cell mergedCell = row.createCell(col);
                        mergedCell.setCellStyle(mergedCellStyle);
                    }
                    // 然后执行合并操作
                    sheet.addMergedRegion(new CellRangeAddress(firow, firow, startCol, endCol));
                    // 只在起始单元格设置数据
                    Cell getCas = row.getCell(startCol);
                    getCas.setCellStyle(mergedCellStyle);
                    style2.setWrapText(true); // 启用自动换行
                    getCas.setCellStyle(style2);
                    getCas.setCellValue(caseTitle);
                    // 只在起始单元格设置数据
                    //ces.setCellValue(caseTitle);
@@ -463,6 +487,11 @@
//                    row.createCell(0).setCellValue("案卷题名:");
                    firow = firow + 1;
                    row = sheet.createRow(firow);
                    // 设置表头高度为43.2
                    row.setHeight((short)(43.2*20));
                    System.out.println("++++++++++++++++++++++++++---------++++++++++++");
                    System.out.println(firow);
                    column = 0;
@@ -470,6 +499,8 @@
                    // 普通sheet处理
                 //   recordId = (DocumentMaterialsVo)list.get(0)
                    row = sheet.createRow(0);
                    // 设置表头高度为43.2
                    row.setHeight((short)(43.2*20));
                    column = 0;
                }
//                // 产生一行
@@ -487,19 +518,46 @@
                //写入签名
                System.out.println(list.get(0).getDataset().size()+"aaaaaaaaaaaaaaaaaaa0999");
                row = sheet.createRow(list.get(0).getDataset().size()+4);
                row = sheet.createRow(list.get(0).getDataset().size()+5);
                //
                                    CellStyle style4 = wb.createCellStyle();
                    Font font4 = wb.createFont();
                    font4.setBold(true);
                    font4.setFontHeightInPoints((short) 12);
                    font4.setFontName("宋体");
                    style4.setFont(font4);
                int in = 0 ;
                for(int i = 0; i < sigArr.size(); i++) {
                    row.createCell(in).setCellValue(sigArr.get(i));
                    in = in + 3;
                for (String s : sigArr) {
                    Cell clr = row.createCell(in);
                    System.out.println(s);
                    clr.setCellStyle(style4);
                    clr.setCellValue(s);
                    in = in + 2;
                }
                System.out.println(in);
            //    row = sheet.createRow(0);
               // row = sheet.createRow(list.get(0).getDataset().size() + 7);
                //写入注释
                for(int i = 0; i < arrAn.size();i++) {
                    row = sheet.createRow(list.get(0).getDataset().size() + 5+i);
                    int ri = list.get(0).getDataset().size() + 5+i;
                   // System.out.println(arrAn.get(i));
                    row = sheet.createRow(list.get(0).getDataset().size() + 7+i);
                    int ri = list.get(0).getDataset().size() + 7+i;
                    sheet.addMergedRegion(new CellRangeAddress(ri, ri, 0, 3));
                    if(i==0)
                        row.createCell(0).setCellValue("注:    "+(i+1)+"、"+arrAn.get(i));
                    else
                        row.createCell(0).setCellValue("       "+(i+1)+"、"+arrAn.get(i));
                    row.createCell(0).setCellValue(i+1+"、"+arrAn.get(i));
                }
            }
@@ -637,7 +695,7 @@
        style.setBorderBottom(BorderStyle.THIN);
        style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
        Font dataFont = wb.createFont();
        dataFont.setFontName("Arial");
        dataFont.setFontName("宋体");
        dataFont.setFontHeightInPoints((short) 10);
        style.setFont(dataFont);
        styles.put("data", style);
@@ -662,9 +720,9 @@
                    style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
                }*/
                Font headerFont = wb.createFont();
                headerFont.setFontName("Arial");
                headerFont.setFontHeightInPoints((short) 10);
                headerFont.setBold(false);
                headerFont.setFontName("宋体");
                headerFont.setFontHeightInPoints((short) 11);
                headerFont.setBold(true);
                headerFont.setColor(excel.headerColor().index);
                style.setFont(headerFont);
                headerStyles.put(key, style);
@@ -678,7 +736,7 @@
        // 设置单元格内容自动换行
        style.setWrapText(true);
        Font totalFont = wb.createFont();
        totalFont.setFontName("Arial");
        totalFont.setFontName("宋体");
        totalFont.setFontHeightInPoints((short) 10);
        style.setFont(totalFont);
        styles.put("total", style);
@@ -1163,3 +1221,4 @@