浏览代码

Merge remote-tracking branch 'origin/master'

全业务考评 1 年之前
父节点
当前提交
f803b21549
共有 1 个文件被更改,包括 36 次插入2 次删除
  1. 36 2
      ims-service/ims-eval/src/main/java/com/ims/eval/util/ExcelUtils.java

+ 36 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/util/ExcelUtils.java

@@ -262,7 +262,13 @@ public class ExcelUtils {
 		Sheet sheet = workbook.createSheet("Sheet1");
 		Sheet sheet = workbook.createSheet("Sheet1");
 
 
 		// 设置列宽
 		// 设置列宽
-		sheet.setColumnWidth(0, 256 * 25);
+		sheet.setColumnWidth(0, 256 * 20);
+		sheet.setColumnWidth(1, 256 * 20);
+		sheet.setColumnWidth(2, 256 * 20);
+		sheet.setColumnWidth(3, 256 * 20);
+		sheet.setColumnWidth(4, 256 * 20);
+		sheet.setColumnWidth(5, 256 * 20);
+		sheet.setColumnWidth(6, 256 * 20);
 
 
 		//设置合并单元格
 		//设置合并单元格
 		sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
 		sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 6));
@@ -306,7 +312,7 @@ public class ExcelUtils {
 		for (int i = 0; i < summaryInformationDTOList.size(); i++) {
 		for (int i = 0; i < summaryInformationDTOList.size(); i++) {
 			Row row = sheet.createRow(rowIndex);
 			Row row = sheet.createRow(rowIndex);
 			row.setHeightInPoints(Float.parseFloat("30"));
 			row.setHeightInPoints(Float.parseFloat("30"));
-			CellStyle cellStyle = createContentStyle(workbook, sheet, rowIndex);
+			CellStyle cellStyle = createContentStyle1(workbook, sheet, rowIndex);
 			Cell indexCell = row.createCell(0);
 			Cell indexCell = row.createCell(0);
 			indexCell.setCellValue(i + 1);
 			indexCell.setCellValue(i + 1);
 			indexCell.setCellStyle(cellStyle);
 			indexCell.setCellStyle(cellStyle);
@@ -446,6 +452,34 @@ public class ExcelUtils {
 		}
 		}
 		return style;
 		return style;
 	}
 	}
+
+	private static CellStyle createContentStyle1(Workbook workbook, Sheet sheet, int rowIndex) {
+		CellStyle style = workbook.createCellStyle();
+		style.setAlignment(HorizontalAlignment.CENTER);
+		style.setVerticalAlignment(VerticalAlignment.CENTER);
+		style.setBorderTop(BorderStyle.THIN);
+		style.setBorderBottom(BorderStyle.THIN);
+		style.setBorderLeft(BorderStyle.THIN);
+		style.setBorderRight(BorderStyle.THIN);
+		Font font = workbook.createFont();
+		font.setFontHeightInPoints((short) 12);
+		font.setColor(IndexedColors.BLACK.getIndex());
+		style.setFont(font);
+		for (int i = rowIndex; i <= rowIndex; i++) {
+			for (int j = 2; j <= 3; j++) {
+				Row mergedRow = sheet.getRow(i);
+				if (mergedRow == null) {
+					mergedRow = sheet.createRow(i);
+				}
+				Cell mergedCell = mergedRow.getCell(j);
+				if (mergedCell == null) {
+					mergedCell = mergedRow.createCell(j);
+				}
+				mergedCell.setCellStyle(style);
+			}
+		}
+		return style;
+	}
 }
 }