From 2f1ae9c10a1751438d09b3d848677deb883631aa Mon Sep 17 00:00:00 2001
From: fei <791364011@qq.com>
Date: 星期三, 14 一月 2026 11:28:16 +0800
Subject: [PATCH] 修改了对应代码

---
 ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java |  366 +++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 291 insertions(+), 75 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java
index 96852e9..99871c7 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtilManySheetFour.java
@@ -12,12 +12,16 @@
 import com.ruoyi.common.utils.file.FileTypeUtils;
 import com.ruoyi.common.utils.file.ImageUtils;
 import com.ruoyi.common.utils.reflect.ReflectUtils;
+import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
+import org.apache.poi.hssf.usermodel.HSSFDataValidation;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellRangeAddressList;
-import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
 import org.apache.poi.xssf.usermodel.XSSFDataValidation;
+import org.apache.poi.xssf.usermodel.XSSFRichTextString;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -255,8 +259,11 @@
      * @throws IOException
      */
     public void exportExcel(HttpServletResponse response, List<T> list, String sheetName) throws IOException {
-        response.setContentType("application/vnd.ms-excel");
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
         response.setCharacterEncoding("utf-8");
+        // 璁剧疆鏂囦欢鍚�
+        String fileName = UUID.randomUUID() + "_"  + ".xlsx";
+        response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
         this.init(list, sheetName, Excel.Type.EXPORT);
         exportExcel(response.getOutputStream());
     }
@@ -269,10 +276,21 @@
      * @return 缁撴灉
      * @throws IOException
      */
+    /**
+     * 瀵筶ist鏁版嵁婧愬皢鍏堕噷闈㈢殑鏁版嵁瀵煎叆鍒癳xcel琛ㄥ崟
+     *
+     * @param response  杩斿洖鏁版嵁
+     * @param list      瀵煎嚭鏁版嵁闆嗗悎
+     * @return 缁撴灉
+     * @throws IOException
+     */
     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.openxmlformats-officedocument.spreadsheetml.sheet");
+        response.setCharacterEncoding("utf-8");
+        // 璁剧疆鏂囦欢鍚�
+        String fileName = UUID.randomUUID() + "_" + ".xlsx";
+        response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
 
         try {
             createWorkbook();
@@ -289,44 +307,77 @@
                 int column = 0;
                 if(index == 0) {
                     // 鍚堝苟绗竴琛岀殑鍓�5涓崟鍏冩牸
-                    sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 8));
 
+                    // 蹇呴』鍏堣缃负true
+                    // 椤甸潰甯冨眬璁剧疆
+                    sheet.setAutobreaks(true);
+                    sheet.setFitToPage(true);
+
+                    // 鑾峰彇鎵撳嵃璁剧疆
+                    PrintSetup printSetup = sheet.getPrintSetup();
+
+                    // 璁剧疆涓�1椤靛搴�
+                    printSetup.setFitWidth((short) 1);   // 瀹藉害璋冩暣涓�1椤�
+                    printSetup.setFitHeight((short) 0);  // 楂樺害涓嶉檺鍒�
+
+                    // 鍏朵粬鎵撳嵃璁剧疆
+                    printSetup.setPaperSize(PrintSetup.A4_PAPERSIZE);  // A4绾�
+                    printSetup.setLandscape(true);  // 绾靛悜鎵撳嵃
 
 
                     // 鍒涘缓琛屽苟璁剧疆楂樺害
                      row = sheet.createRow(firow);
-                    row.setHeight((short)(40 * 40));
                     //鐢熸垚浜岀淮鐮�
                     if(includeQrCode)
                     {
-                        Cell cell = row.createCell(6);
+                        row.setHeight((short)(55.8 * 20));
 
+                        Cell cell = row.createCell(0);
+//                        for(int cl = 1 ; cl <=8; cl++)
+//                            cell = row.createCell(cl);
+//
+//
+//                        for (int col = 4; col <= 7; col++) {
+//                            row.getSheet().setColumnWidth(col, 15 * 256); // 姣忓垪15瀛楃瀹�
+                //        }
+
+                        int margin = -40* 9525;
+                        int mary = -11 * 9525;
+                        XSSFClientAnchor anchor = new XSSFClientAnchor(
+                                0,          // dx1
+                                0,          // dy1
+                                margin,     // dx2锛氬彸杈圭晫宸︾Щ10鍍忕礌
+                                mary,          // dy2
+                                (short)5,   // col1
+                                0,          // row1
+                                (short)9,   // col2
+                                1          // row2
+                        );
                         // 璁剧疆鍥剧墖澶у皬鍜屼綅缃�
-                        ClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, (short) (cell.getColumnIndex()+1), cell.getRow().getRowNum(), (short) (cell.getColumnIndex() +2),
-                                cell.getRow().getRowNum() + 1);
+                     //   ClientAnchor anchor = new XSSFClientAnchor(0, 0, 600, 150, (short)0, 0, (short)6, 1);
+                    //   anchor.setDx2(488);
+                    //   anchor.setDy2(10);
+                   //     anchor.setAnchorType(ClientAnchor.AnchorType.MOVE_AND_RESIZE);
                         // 璁$畻灞呬腑浣嶇疆
-//                    int col1 = 0; // 涓棿鍒�
-//                    int col2 = col1 + 2;
-//                    anchor.setCol1(col1);
-//                    anchor.setCol2(col2);
-//                    anchor.setDx1(100);
-//                    anchor.setDy1(0);
-//                    anchor.setDx2(255); // 瀹藉害
-//                    anchor.setDy2(255); // 楂樺害
-                        anchor.setRow1(1);
-                        anchor.setRow2(1);
-                        byte[] data = bt;
-                        anchor.setDx1(2400000);
-                        anchor.setDy1(-10);
 
-                        anchor.setDy2(-800000);
+
+                        // 璁$畻灞呬腑浣嶇疆
+//                        int col1 = 4; // 涓棿鍒�
+//                        int col2 = col1 + 3;
+//                        anchor.setCol1(col1);
+//                        anchor.setCol2(col2);
+//                        anchor.setRow1(0);
+//                        anchor.setRow2(1);
+
+                        byte[] data = bt;
+                 
                         // 鑾峰彇鍥剧墖鍘熷灏哄
                         BufferedImage image = ImageIO.read(new ByteArrayInputStream(data));
-                        double widthInEMU = image.getWidth() * 9525 * 0.2;
-                        double heightInEMU = image.getHeight() * 9525;
+//                        double widthInEMU = image.getWidth() * 9525 * 0.2;
+//                        double heightInEMU = image.getHeight() * 9525;
 
                         // 璁剧疆鍥剧墖鍘熷灏哄
-                        anchor.setDx2(-100000); // 鍘熷瀹藉害
+                    //    anchor.setDx2(-100000); // 鍘熷瀹藉害
                         //   anchor.setDy2((int)heightInEMU); // 鍘熷楂樺害
 //anchor.setCol1(5); // 浠庣6鍒楀紑濮嬫樉绀�
 //anchor.setCol2(10); // 鍒扮11鍒楃粨鏉�
@@ -340,12 +391,16 @@
                         firow = firow + 1;
                         row = sheet.createRow(firow);
                     }
-                  //  sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 7));
+                    else
+                        row.setHeight((short)(33 * 20));
+                  //  sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 8));
+
+                    //  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("鏂囦欢鏉愭枡绉讳氦鐩綍娓呭崟(鍗峰唴绾�)");
@@ -353,26 +408,106 @@
                     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.createCell(0).setCellValue("鍙戞枃鍙�:");
-                    sheet.addMergedRegion(new CellRangeAddress(firow, firow, 1, 3));
-                    row.createCell(1).setCellValue(inquiryNumber);
-                    row.createCell(4).setCellValue("妗堝嵎棰樺悕:");
-                    sheet.addMergedRegion(new CellRangeAddress(firow, firow, 5, 9));
 
-                    //   row.createCell(4).setCellValue("妗e彿:");
-                    //鎷垮埌妗e彿
-                    row.createCell(5).setCellValue(caseTitle);
+                    // 灏嗗浐瀹氳楂樻敼涓鸿嚜鍔ㄨ楂橈紝浠ヤ究鍐呭鑳藉畬鏁存樉绀哄湪鍚堝苟鍖哄煙
+                    row.setHeight((short)(27.6*20));
+                    //
+                    CellStyle style1 = wb.createCellStyle();
+                    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 = 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(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 = 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);
+
+                    style2.setWrapText(true); // 鍚敤鑷姩鎹㈣
+
+                    getCas.setCellStyle(style2);
+                    getCas.setCellValue(caseTitle);
+                    // 鍙湪璧峰鍗曞厓鏍艰缃暟鎹�
+                    //ces.setCellValue(caseTitle);
+
+                    // 璁剧疆鑷姩鎹㈣
+//                    row = sheet.createRow(2);
+//                    row.createCell(0).setCellValue("妗堝嵎棰樺悕:");
+
+
+
+                    // 璁剧疆鑷姩鎹㈣
 //                    row = sheet.createRow(2);
 //                    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;
@@ -380,6 +515,8 @@
                     // 鏅�歴heet澶勭悊
                  //   recordId = (DocumentMaterialsVo)list.get(0)
                     row = sheet.createRow(0);
+                    // 璁剧疆琛ㄥご楂樺害涓�43.2
+                    row.setHeight((short)(43.2*20));
                     column = 0;
                 }
 //                // 浜х敓涓�琛�
@@ -397,19 +534,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));
                 }
 
             }
@@ -442,8 +606,11 @@
      * @return 缁撴灉
      */
     public void importTemplateExcel(HttpServletResponse response, String sheetName) throws IOException {
-        response.setContentType("application/vnd.ms-excel");
+        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
         response.setCharacterEncoding("utf-8");
+        // 璁剧疆鏂囦欢鍚�
+        String fileName = UUID.randomUUID() + "_"  + ".xlsx";
+        response.setHeader("Content-Disposition", "attachment; filename=" );
         this.init(null, sheetName, Excel.Type.IMPORT);
         exportExcel(response.getOutputStream());
     }
@@ -533,6 +700,8 @@
         CellStyle style = wb.createCellStyle();
         style.setAlignment(HorizontalAlignment.CENTER);
         style.setVerticalAlignment(VerticalAlignment.CENTER);
+        // 璁剧疆鍗曞厓鏍煎唴瀹硅嚜鍔ㄦ崲琛�
+        style.setWrapText(true);
         style.setBorderRight(BorderStyle.THIN);
         style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex());
         style.setBorderLeft(BorderStyle.THIN);
@@ -542,30 +711,48 @@
         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);
 
-        style = wb.createCellStyle();
-        style.cloneStyleFrom(styles.get("data"));
-        style.setAlignment(HorizontalAlignment.CENTER);
-        style.setVerticalAlignment(VerticalAlignment.CENTER);
-        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);
+        // 鍒涘缓琛ㄥご鏍峰紡鏄犲皠锛屾牴鎹瓻xcel娉ㄨВ鍔ㄦ�佺敓鎴�
+        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("瀹嬩綋");
+                headerFont.setFontHeightInPoints((short) 11);
+                headerFont.setBold(true);
+                headerFont.setColor(excel.headerColor().index);
+                style.setFont(headerFont);
+                headerStyles.put(key, style);
+            }
+        }
+        styles.putAll(headerStyles);
 
         style = wb.createCellStyle();
         style.setAlignment(HorizontalAlignment.CENTER);
         style.setVerticalAlignment(VerticalAlignment.CENTER);
+        // 璁剧疆鍗曞厓鏍煎唴瀹硅嚜鍔ㄦ崲琛�
+        style.setWrapText(true);
         Font totalFont = wb.createFont();
-        totalFont.setFontName("Arial");
+        totalFont.setFontName("瀹嬩綋");
         totalFont.setFontHeightInPoints((short) 10);
         style.setFont(totalFont);
         styles.put("total", style);
@@ -573,16 +760,22 @@
         style = wb.createCellStyle();
         style.cloneStyleFrom(styles.get("data"));
         style.setAlignment(HorizontalAlignment.LEFT);
+        // 璁剧疆鍗曞厓鏍煎唴瀹硅嚜鍔ㄦ崲琛�
+        style.setWrapText(true);
         styles.put("data1", style);
 
         style = wb.createCellStyle();
         style.cloneStyleFrom(styles.get("data"));
         style.setAlignment(HorizontalAlignment.CENTER);
+        // 璁剧疆鍗曞厓鏍煎唴瀹硅嚜鍔ㄦ崲琛�
+        style.setWrapText(true);
         styles.put("data2", style);
 
         style = wb.createCellStyle();
         style.cloneStyleFrom(styles.get("data"));
         style.setAlignment(HorizontalAlignment.RIGHT);
+        // 璁剧疆鍗曞厓鏍煎唴瀹硅嚜鍔ㄦ崲琛�
+        style.setWrapText(true);
         styles.put("data3", style);
 
         return styles;
@@ -597,7 +790,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;
     }
 
@@ -656,17 +851,17 @@
             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())) {
             // 杩欓噷榛樿璁句簡2-101鍒楁彁绀�.
-            setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column);
+            setCellPrompt(sheet, "", attr.prompt(), 1, 100, column, column);
         }
         // 濡傛灉璁剧疆浜哻ombo灞炴�у垯鏈垪鍙兘閫夋嫨涓嶈兘杈撳叆
         if (attr.combo().length > 0) {
             // 杩欓噷榛樿璁句簡2-101鍒楀彧鑳介�夋嫨涓嶈兘杈撳叆.
-            setXSSFValidation(sheet, attr.combo(), 1, 100, column, column);
+            setCellValidation(sheet, attr.combo(), 1, 100, column, column);
         }
     }
 
@@ -676,15 +871,23 @@
     public Cell addCell(Excel attr, Row row, T vo, Field field, int column) {
         Cell cell = null;
         try {
-            // 璁剧疆琛岄珮
-            row.setHeight(maxHeight);
+            // 璁剧疆琛岄珮涓鸿嚜鍔ㄨ皟鏁�
+            row.setHeight((short) -1);
             // 鏍规嵁Excel涓缃儏鍐靛喅瀹氭槸鍚﹀鍑�,鏈変簺鎯呭喌闇�瑕佷繚鎸佷负绌�,甯屾湜鐢ㄦ埛濉啓杩欎竴鍒�.
             if (attr.isExport()) {
                 // 鍒涘缓cell
                 cell = row.createCell(column);
-//                attr.align();
-//                int align = attr.align().value;
-//                cell.setCellStyle(styles.get("data" + (align >= 1 && align <= 3 ? align : "")));
+                // 璁剧疆鍗曞厓鏍兼牱寮�
+                HorizontalAlignment align = attr.align();
+                String styleKey = "data";
+                if (align == HorizontalAlignment.LEFT) {
+                    styleKey = "data1";
+                } else if (align == HorizontalAlignment.CENTER) {
+                    styleKey = "data2";
+                } else if (align == HorizontalAlignment.RIGHT) {
+                    styleKey = "data3";
+                }
+                cell.setCellStyle(styles.get(styleKey));
 
                 // 鐢ㄤ簬璇诲彇瀵硅薄涓殑灞炴��
                 Object value = getTargetValue(vo, field, attr);
@@ -710,7 +913,7 @@
     }
 
     /**
-     * 璁剧疆 POI XSSFSheet 鍗曞厓鏍兼彁绀�
+     * 璁剧疆鍗曞厓鏍兼彁绀�
      *
      * @param sheet         琛ㄥ崟
      * @param promptTitle   鎻愮ず鏍囬
@@ -720,7 +923,7 @@
      * @param firstCol      寮�濮嬪垪
      * @param endCol        缁撴潫鍒�
      */
-    public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow,
+    public void setCellPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow,
                               int firstCol, int endCol) {
         DataValidationHelper helper = sheet.getDataValidationHelper();
         DataValidationConstraint constraint = helper.createCustomConstraint("DD1");
@@ -742,7 +945,7 @@
      * @param endCol   缁撴潫鍒�
      * @return 璁剧疆濂界殑sheet.
      */
-    public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) {
+    public void setCellValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) {
         DataValidationHelper helper = sheet.getDataValidationHelper();
         // 鍔犺浇涓嬫媺鍒楄〃鍐呭
         DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist);
@@ -752,10 +955,8 @@
         DataValidation dataValidation = helper.createValidation(constraint, regions);
         // 澶勭悊Excel鍏煎鎬ч棶棰�
         if (dataValidation instanceof XSSFDataValidation) {
-            dataValidation.setSuppressDropDownArrow(true);
-            dataValidation.setShowErrorBox(true);
-        } else {
             dataValidation.setSuppressDropDownArrow(false);
+            dataValidation.setShowErrorBox(true);
         }
 
         sheet.addValidationData(dataValidation);
@@ -952,7 +1153,7 @@
      * 鍒涘缓涓�涓伐浣滅翱
      */
     public void createWorkbook() {
-        this.wb = new SXSSFWorkbook(500);
+        this.wb = new XSSFWorkbook();
     }
 
     /**
@@ -1022,3 +1223,18 @@
         return val;
     }
 }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

--
Gitblit v1.9.1