PoI 3.17 已過時代碼對比


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);

待更新 . .


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM