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

填充模式

旧版本: cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

新版本: cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

posted @   爱跳舞的程序员  阅读(3890)  评论(1编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
历史上的今天:
2019-01-11 LigerUi遮罩的两个方法
点击右上角即可分享
微信分享提示