Quellcode durchsuchen

考勤统计导出调整

dzx vor 19 Stunden
Ursprung
Commit
fc6190cc12

+ 8 - 8
src/main/java/com/xjrsoft/module/attendance/service/impl/AttendanceStatisticsServiceImpl.java

@@ -517,6 +517,9 @@ public class AttendanceStatisticsServiceImpl extends MPJBaseServiceImpl<Attendan
                 CellStyle cellStyle = workbook.createCellStyle();
                 cellStyle.setFont(font); // 将字体应用到样式
                 cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+                if(i > 3 && i < 8){
+                    cellStyle.setAlignment(HorizontalAlignment.CENTER);
+                }
 
                 Cell row1cell2 = dataRow.createCell(i);
                 row1cell2.setCellValue(content);
@@ -611,49 +614,46 @@ public class AttendanceStatisticsServiceImpl extends MPJBaseServiceImpl<Attendan
         row1cell1.setCellValue("序号");
         row1cell1.setCellStyle(cellStyle);
         sheet.addMergedRegion(new CellRangeAddress(rowNumber, rowNumber + 1, 0, 0));
-        sheet.setColumnWidth(0, 32*256);
+
 
         Cell row1cell2 = row1.createCell(1);
         row1cell2.setCellValue("姓名");
         row1cell2.setCellStyle(cellStyle);
         sheet.addMergedRegion(new CellRangeAddress(rowNumber, rowNumber + 1, 1, 1));
-        sheet.setColumnWidth(1, 32*256);
 
         Cell row1cell3 = row1.createCell(2);
         row1cell3.setCellValue("工号");
         row1cell3.setCellStyle(cellStyle);
         sheet.addMergedRegion(new CellRangeAddress(rowNumber, rowNumber + 1, 2, 2));
-        sheet.setColumnWidth(2, 32*256);
 
         Cell row1cell4 = row1.createCell(3);
         row1cell4.setCellValue("组织机构");
         row1cell4.setCellStyle(cellStyle);
         sheet.addMergedRegion(new CellRangeAddress(rowNumber, rowNumber + 1, 3, 3));
-        sheet.setColumnWidth(3, 64*256);
 
         Cell row1cell8 = row1.createCell(4);
         row1cell8.setCellValue("考勤组应出勤天数");
         row1cell8.setCellStyle(cellStyle);
         sheet.addMergedRegion(new CellRangeAddress(rowNumber, rowNumber + 1, 4, 4));
-        sheet.setColumnWidth(4, 132*256);
 
         Cell row1cell5 = row1.createCell(5);
         row1cell5.setCellValue("正常考勤次数");
         row1cell5.setCellStyle(cellStyle);
         sheet.addMergedRegion(new CellRangeAddress(rowNumber, rowNumber + 1, 5, 5));
-        sheet.setColumnWidth(5, 100*256);
 
         Cell row1cell6 = row1.createCell(6);
         row1cell6.setCellValue("请假次数");
         row1cell6.setCellStyle(cellStyle);
         sheet.addMergedRegion(new CellRangeAddress(rowNumber, rowNumber + 1, 6, 6));
-        sheet.setColumnWidth(6, 64*256);
 
         Cell row1cell7 = row1.createCell(7);
         row1cell7.setCellValue("缺勤次数");
         row1cell7.setCellStyle(cellStyle);
         sheet.addMergedRegion(new CellRangeAddress(rowNumber, rowNumber + 1, 7, 7));
-        sheet.setColumnWidth(7, 64*256);
+
+        for(int i = 0; i < 7; i ++){
+            sheet.autoSizeColumn(i);
+        }
 
         int cellNumber = 8;
         for (String dayOfWeek : weekList) {