diff --git a/src/com/engine/salary/util/excel/ExcelUtilPlus.java b/src/com/engine/salary/util/excel/ExcelUtilPlus.java index f301e8c23..9da402ce7 100644 --- a/src/com/engine/salary/util/excel/ExcelUtilPlus.java +++ b/src/com/engine/salary/util/excel/ExcelUtilPlus.java @@ -134,7 +134,7 @@ public class ExcelUtilPlus { rowZeroCell.setCellValue(columnGroupItem.getText().toString()); rowZeroCell.setCellStyle(titleCellStyle); //设置列宽 - sheet.setColumnWidth(i, Math.max(12, columnGroupItem.getText().length() * 4) * 256); + sheet.setColumnWidth(i, Math.min(255, Math.max(12, columnGroupItem.getText().length() * 4)) * 256); patternList.add(columnGroupItem.getPattern()); } @@ -262,7 +262,7 @@ public class ExcelUtilPlus { //遍历设置列宽 List header = rowList.get(0); for (int i = 0; i < header.size(); i++) { - sheet.setColumnWidth(i, Math.max(12, header.get(i).toString().length() * 4) * 256); + sheet.setColumnWidth(i, Math.min(255, Math.max(12, header.get(i).toString().length() * 4)) * 256); } for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) { @@ -349,7 +349,7 @@ public class ExcelUtilPlus { //遍历设置列宽 List header = rowList.get(0); for (int i = 0; i < header.size(); i++) { - sheet.setColumnWidth(i, Math.max(12, header.get(i).toString().length() * 4) * 256); + sheet.setColumnWidth(i, Math.min(255, Math.max(12, header.get(i).toString().length() * 4)) * 256); } for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) { @@ -454,7 +454,7 @@ public class ExcelUtilPlus { //遍历设置列宽 List header = rowList.get(0); for (int i = 0; i < header.size(); i++) { - sheet.setColumnWidth(i, Math.max(12, header.get(i).toString().length() * 4) * 256); + sheet.setColumnWidth(i, Math.min(255, Math.max(12, header.get(i).toString().length() * 4)) * 256); } for (int rowIndex = 0; rowIndex < rowList.size(); rowIndex++) { @@ -588,7 +588,7 @@ public class ExcelUtilPlus { rowOneCell.setCellValue(columnGroupItem.getText().toString()); rowOneCell.setCellStyle(titleCellStyle); //设置列宽 - sheet.setColumnWidth(startIndex, Math.max(12, columnGroupItem.getText().length() * 4) * 256); + sheet.setColumnWidth(startIndex, Math.min(255, Math.max(12, columnGroupItem.getText().length() * 4)) * 256); startIndex++; patternList.add(columnGroupItem.getPattern()); } else { @@ -610,7 +610,7 @@ public class ExcelUtilPlus { subHeader.setCellValue(childrenItem.getText().toString()); subHeader.setCellStyle(titleCellStyle); //设置列宽 - sheet.setColumnWidth(startIndex + j, Math.max(12, childrenItem.getText().length() * 4) * 256); + sheet.setColumnWidth(startIndex + j, Math.min(255, Math.max(12, childrenItem.getText().length() * 4)) * 256); patternList.add(childrenItem.getPattern()); } @@ -789,7 +789,7 @@ public class ExcelUtilPlus { rowOneCell.setCellValue(columnGroupItem.getText().toString()); rowOneCell.setCellStyle(titleCellStyle); //设置列宽 - sheet.setColumnWidth(startIndex, Math.max(12, columnGroupItem.getText().length() * 4) * 256); + sheet.setColumnWidth(startIndex, Math.min(255, Math.max(12, columnGroupItem.getText().length() * 4)) * 256); startIndex++; } else { List childrenList = columnGroupItem.getChildren(); @@ -810,7 +810,7 @@ public class ExcelUtilPlus { subHeader.setCellValue(childrenItem.getText().toString()); subHeader.setCellStyle(titleCellStyle); //设置列宽 - sheet.setColumnWidth(startIndex + j, Math.max(12, childrenItem.getText().length() * 4) * 256); + sheet.setColumnWidth(startIndex + j, Math.min(255, Math.max(12, childrenItem.getText().length() * 4)) * 256); } startIndex += childrenList.size();