PoI 3.17 已過時代碼對比
顏色定義變化
舊版本 : HSSFColor.BLACK.index
新版本 : IndexedColors.BLACK.index
獲取單元格格式
舊版本 : cell.getCellType 與之應對的單元格格式 HSSFCell.CELL_TYPE_BLANK
新版本 : cell.getCellTypeEnum 與之對應的單元格格式 BLANK (org.apache.poi.ss.usermodel.CellType.BLANK)
設置單元格格式
舊版本 : row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
新版本 : row.getCell(0).setCellType(CellType.STRING);
設置單元格垂直居中樣式
舊版本 : XSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER); // 居中
cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);//垂直
新版本 : XSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setAlignment(HorizontalAlignment.CENTER); // 居中
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); //垂直
設置邊框
舊版本 : cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); //下邊框
新版本 : cellStyle.setBorderBottom(BorderStyle.THIN); //下邊框
合並單元格
舊版本 : sheet.addMergedRegion(new CellRangeAddress(1, 1,(short) 0, (short) 0));// 起始行,結束行,起始列,結束列
新版本 : sheet.addMergedRegion(new Region(1, (short) 0, 1,(short) 0));// 起始行,起始列,結束行,結束列
設置字體加粗
舊版本: font.setBoldweight((short) 400);
新版本: font.setBold(true);
待更新 . .