Просмотр исходного кода

电缆分段表导出代码上传

user5 3 лет назад
Родитель
Сommit
6685f76d16

+ 0 - 5
pom.xml

@@ -817,11 +817,6 @@
             <version>1.7.0</version>
         </dependency>
         <!-- UTILS end -->
-        <dependency>
-            <groupId>org.apache.ant</groupId>
-            <artifactId>ant</artifactId>
-            <version>1.10.5</version>
-        </dependency>
     </dependencies>
 
 </project>

+ 83 - 36
src/main/java/com/jeeplus/modules/sg/raiseCapitalDesign/utils/RaiseCapitalDesignExportUtil.java

@@ -654,8 +654,9 @@ public class RaiseCapitalDesignExportUtil {
      */
     public static void getSheetCableList(Sheet sheet, CableSectionData cableSectionData, RaiseCapital raiseCapital, Workbook workbook) {
         if (sheet != null) {
-            CellStyle style = getCellStyleFont(workbook);
-            CellStyle cellStyle = getCellStyle(workbook);
+            CellStyle cellStyle = getNewCellStyleFont(workbook);
+            CellStyle cellStyleNoAlignment = getNewCellStyleFontNoAlignment(workbook);//不居中
+            CellStyle cellStyleNoBoldweight = getNewCellStyleFontNoBoldweight(workbook);//不加粗
 
             XSSFRow row = (XSSFRow) sheet.getRow(0);
             XSSFCell cell = row.getCell(0);
@@ -681,47 +682,47 @@ public class RaiseCapitalDesignExportUtil {
                 if(cableFourHundredList.size()>=i){
                     cableFourHundred = cableFourHundredList.get(i-1);
                     //对数据进行处理
-                    disposeCableRowData(row,0,cableFourHundred,cellStyle);
+                    disposeCableRowData(row,0,cableFourHundred,cellStyle,cellStyleNoBoldweight);
                 }else{
-                    disposeCableRowNoData(row,0,cableFactor,cellStyle);
+                    disposeCableRowNoData(row,0,cableFactor,cellStyle,cellStyleNoBoldweight);
                 }
                 CableSectionInfo cableThreeHundred = null;  //3×300mm²
                 if(cableThreeHundredList.size()>=i){
                     cableThreeHundred = cableThreeHundredList.get(i-1);
-                    disposeCableRowData(row,8,cableThreeHundred,cellStyle);
+                    disposeCableRowData(row,8,cableThreeHundred,cellStyle,cellStyleNoBoldweight);
                 }else{
-                    disposeCableRowNoData(row,8,cableFactor,cellStyle);
+                    disposeCableRowNoData(row,8,cableFactor,cellStyle,cellStyleNoBoldweight);
                 }
                 CableSectionInfo cableTwoHundredForty = null;   //3×240mm²
                 if(cableTwoHundredFortyList.size()>=i){
                     cableTwoHundredForty = cableTwoHundredFortyList.get(i-1);
-                    disposeCableRowData(row,16,cableTwoHundredForty,cellStyle);
+                    disposeCableRowData(row,16,cableTwoHundredForty,cellStyle,cellStyleNoBoldweight);
                 }else{
-                    disposeCableRowNoData(row,16,cableFactor,cellStyle);
+                    disposeCableRowNoData(row,16,cableFactor,cellStyle,cellStyleNoBoldweight);
                 }
                 CableSectionInfo cableHundredAndTwenty = null;  //3×120mm²
                 if(cableHundredAndTwentyList.size()>=i){
                     cableHundredAndTwenty = cableHundredAndTwentyList.get(i-1);
-                    disposeCableRowData(row,24,cableHundredAndTwenty,cellStyle);
+                    disposeCableRowData(row,24,cableHundredAndTwenty,cellStyle,cellStyleNoBoldweight);
                 }else{
-                    disposeCableRowNoData(row,24,cableFactor,cellStyle);
+                    disposeCableRowNoData(row,24,cableFactor,cellStyle,cellStyleNoBoldweight);
                 }
                 CableSectionInfo cableSeventy = null;       //3×70mm²
                 if(cableSeventyList.size()>=i){
                     cableSeventy = cableSeventyList.get(i-1);
-                    disposeCableRowData(row,32,cableSeventy,cellStyle);
+                    disposeCableRowData(row,32,cableSeventy,cellStyle,cellStyleNoBoldweight);
                 }else{
-                    disposeCableRowNoData(row,32,cableFactor,cellStyle);
+                    disposeCableRowNoData(row,32,cableFactor,cellStyle,cellStyleNoBoldweight);
                 }
             }
 
             //处理总数行
             row = (XSSFRow) sheet.createRow(num + 2);
-            disposeCableRowOverallLength(row,num + 2,0,cellStyle,sheet,cableSectionData.getCableFourHundredListTotal());
-            disposeCableRowOverallLength(row,num + 2,8,cellStyle,sheet,cableSectionData.getCableThreeHundredListTotal());
-            disposeCableRowOverallLength(row,num + 2,16,cellStyle,sheet,cableSectionData.getCableTwoHundredFortyListTotal());
-            disposeCableRowOverallLength(row,num + 2,24,cellStyle,sheet,cableSectionData.getCableHundredAndTwentyListTotal());
-            disposeCableRowOverallLength(row,num + 2,32,cellStyle,sheet,cableSectionData.getCableSeventyListTotal());
+            disposeCableRowOverallLength(row,num + 2,0,cellStyle,cellStyleNoAlignment,sheet,cableSectionData.getCableFourHundredListTotal());
+            disposeCableRowOverallLength(row,num + 2,8,cellStyle,cellStyleNoAlignment,sheet,cableSectionData.getCableThreeHundredListTotal());
+            disposeCableRowOverallLength(row,num + 2,16,cellStyle,cellStyleNoAlignment,sheet,cableSectionData.getCableTwoHundredFortyListTotal());
+            disposeCableRowOverallLength(row,num + 2,24,cellStyle,cellStyleNoAlignment,sheet,cableSectionData.getCableHundredAndTwentyListTotal());
+            disposeCableRowOverallLength(row,num + 2,32,cellStyle,cellStyleNoAlignment,sheet,cableSectionData.getCableSeventyListTotal());
         }
     }
 
@@ -733,7 +734,7 @@ public class RaiseCapitalDesignExportUtil {
      * @param cellStyle 截至列
      * @param sheet
      */
-    private static void disposeCableRowOverallLength(XSSFRow row, Integer lineNum, Integer columnNum, CellStyle cellStyle, Sheet sheet,String cableTotal){
+    private static void disposeCableRowOverallLength(XSSFRow row, Integer lineNum, Integer columnNum, CellStyle cellStyle, CellStyle cellStyleNoAlignment, Sheet sheet,String cableTotal){
         XSSFCell cell = row.getCell(1);
 
         if (row.getCell(columnNum) == null) {
@@ -742,7 +743,7 @@ public class RaiseCapitalDesignExportUtil {
             cell = row.getCell(columnNum);
         }
         cell.setCellValue("总长(km):");
-        cell.setCellStyle(cellStyle);
+        cell.setCellStyle(cellStyleNoAlignment);
 
         //第二列
         if (row.getCell(columnNum+1) == null) {
@@ -751,7 +752,7 @@ public class RaiseCapitalDesignExportUtil {
             cell = row.getCell(columnNum+1);
         }
         cell.setCellValue("");//空行
-        cell.setCellStyle(cellStyle);
+        cell.setCellStyle(cellStyleNoAlignment);
 
         //第三列
         if (row.getCell(columnNum+2) == null) {
@@ -760,7 +761,7 @@ public class RaiseCapitalDesignExportUtil {
             cell = row.getCell(columnNum+2);
         }
         cell.setCellValue("");//空行
-        cell.setCellStyle(cellStyle);
+        cell.setCellStyle(cellStyleNoAlignment);
 
         //第四列
         if (row.getCell(columnNum+3) == null) {
@@ -769,7 +770,7 @@ public class RaiseCapitalDesignExportUtil {
             cell = row.getCell(columnNum+3);
         }
         cell.setCellValue("");//空行
-        cell.setCellStyle(cellStyle);
+        cell.setCellStyle(cellStyleNoAlignment);
 
         //第五列
         if (row.getCell(columnNum+4) == null) {
@@ -778,7 +779,7 @@ public class RaiseCapitalDesignExportUtil {
             cell = row.getCell(columnNum+4);
         }
         cell.setCellValue("");//空行
-        cell.setCellStyle(cellStyle);
+        cell.setCellStyle(cellStyleNoAlignment);
 
         //第六列
         if (row.getCell(columnNum+5) == null) {
@@ -787,7 +788,7 @@ public class RaiseCapitalDesignExportUtil {
             cell = row.getCell(columnNum+5);
         }
         cell.setCellValue("");//系数
-        cell.setCellStyle(cellStyle);
+        cell.setCellStyle(cellStyleNoAlignment);
 
 
         if (row.getCell(columnNum+6) == null) {
@@ -812,7 +813,7 @@ public class RaiseCapitalDesignExportUtil {
      * @param cableData
      * @param cellStyle
      */
-    private static void disposeCableRowData(XSSFRow row, Integer columnNum, CableSectionInfo cableData, CellStyle cellStyle){
+    private static void disposeCableRowData(XSSFRow row, Integer columnNum, CableSectionInfo cableData, CellStyle cellStyle, CellStyle cellStyleNoBoldweight){
 
         XSSFCell cell = row.getCell(1);
         //第一列
@@ -823,7 +824,7 @@ public class RaiseCapitalDesignExportUtil {
         }
         if(cableData != null){
             cell.setCellValue(cableData.getDestination());//400起讫点
-            cell.setCellStyle(cellStyle);
+            cell.setCellStyle(cellStyleNoBoldweight);
         }
 
         //第二列
@@ -834,7 +835,7 @@ public class RaiseCapitalDesignExportUtil {
         }
         if(cableData != null){
             cell.setCellValue(cableData.getPathLength());//400路径长(m)
-            cell.setCellStyle(cellStyle);
+            cell.setCellStyle(cellStyleNoBoldweight);
         }
 
         //第三列
@@ -845,7 +846,7 @@ public class RaiseCapitalDesignExportUtil {
         }
         if(cableData != null){
             cell.setCellValue(cableData.getUpperRod());//400上杆(m)
-            cell.setCellStyle(cellStyle);
+            cell.setCellStyle(cellStyleNoBoldweight);
         }
 
         //第四列
@@ -856,7 +857,7 @@ public class RaiseCapitalDesignExportUtil {
         }
         if(cableData != null){
             cell.setCellValue(cableData.getArrival());//400进站(m)
-            cell.setCellStyle(cellStyle);
+            cell.setCellStyle(cellStyleNoBoldweight);
         }
 
         //第五列
@@ -867,7 +868,7 @@ public class RaiseCapitalDesignExportUtil {
         }
         if(cableData != null){
             cell.setCellValue(cableData.getIncomingEquipment());//400进设备(m)
-            cell.setCellStyle(cellStyle);
+            cell.setCellStyle(cellStyleNoBoldweight);
         }
 
         //第六列
@@ -911,7 +912,7 @@ public class RaiseCapitalDesignExportUtil {
      * @param coefficient   系数
      * @param cellStyle
      */
-    private static void disposeCableRowNoData(XSSFRow row, Integer columnNum, String coefficient, CellStyle cellStyle){
+    private static void disposeCableRowNoData(XSSFRow row, Integer columnNum, String coefficient, CellStyle cellStyle, CellStyle cellStyleNoBoldweight){
 
         XSSFCell cell = row.getCell(1);
         //第一列
@@ -921,7 +922,7 @@ public class RaiseCapitalDesignExportUtil {
             cell = row.getCell(columnNum);
         }
         cell.setCellValue("");//空行
-        cell.setCellStyle(cellStyle);
+        cell.setCellStyle(cellStyleNoBoldweight);
 
         //第二列
         if (row.getCell(columnNum+1) == null) {
@@ -930,7 +931,7 @@ public class RaiseCapitalDesignExportUtil {
             cell = row.getCell(columnNum+1);
         }
         cell.setCellValue("");//空行
-        cell.setCellStyle(cellStyle);
+        cell.setCellStyle(cellStyleNoBoldweight);
 
         //第三列
         if (row.getCell(columnNum+2) == null) {
@@ -939,7 +940,7 @@ public class RaiseCapitalDesignExportUtil {
             cell = row.getCell(columnNum+2);
         }
         cell.setCellValue("");//空行
-        cell.setCellStyle(cellStyle);
+        cell.setCellStyle(cellStyleNoBoldweight);
 
         //第四列
         if (row.getCell(columnNum+3) == null) {
@@ -948,7 +949,7 @@ public class RaiseCapitalDesignExportUtil {
             cell = row.getCell(columnNum+3);
         }
         cell.setCellValue("");//空行
-        cell.setCellStyle(cellStyle);
+        cell.setCellStyle(cellStyleNoBoldweight);
 
         //第五列
         if (row.getCell(columnNum+4) == null) {
@@ -957,7 +958,7 @@ public class RaiseCapitalDesignExportUtil {
             cell = row.getCell(columnNum+4);
         }
         cell.setCellValue("");//空行
-        cell.setCellStyle(cellStyle);
+        cell.setCellStyle(cellStyleNoBoldweight);
 
         //第六列
         if (row.getCell(columnNum+5) == null) {
@@ -1025,4 +1026,50 @@ public class RaiseCapitalDesignExportUtil {
         return style;
     }
 
+    //设置 字体边框
+    public static CellStyle getNewCellStyleFont(Workbook workbook) {
+        XSSFFont font = (XSSFFont) workbook.createFont();
+        font.setFontHeightInPoints((short) 11);//设置字体大小
+        font.setFontName("仿宋_GB2312");
+        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
+        CellStyle style = workbook.createCellStyle();
+        style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 居中
+        style.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
+        style.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
+        style.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
+        style.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
+        style.setFont(font);
+        return style;
+    }
+
+    //设置 字体边框
+    public static CellStyle getNewCellStyleFontNoAlignment(Workbook workbook) {
+        XSSFFont font = (XSSFFont) workbook.createFont();
+        font.setFontHeightInPoints((short) 11);//设置字体大小
+        font.setFontName("仿宋_GB2312");
+        font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//粗体显示
+        CellStyle style = workbook.createCellStyle();
+        style.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
+        style.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
+        style.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
+        style.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
+        style.setFont(font);
+        return style;
+    }
+
+    //设置 字体边框
+    public static CellStyle getNewCellStyleFontNoBoldweight(Workbook workbook) {
+        XSSFFont font = (XSSFFont) workbook.createFont();
+        font.setFontHeightInPoints((short) 11);//设置字体大小
+        font.setFontName("仿宋_GB2312");
+        CellStyle style = workbook.createCellStyle();
+        style.setAlignment(HSSFCellStyle.ALIGN_CENTER); // 居中
+        style.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框
+        style.setBorderLeft(HSSFCellStyle.BORDER_THIN);//左边框
+        style.setBorderTop(HSSFCellStyle.BORDER_THIN);//上边框
+        style.setBorderRight(HSSFCellStyle.BORDER_THIN);//右边框
+        style.setFont(font);
+        return style;
+    }
+
 }