poi版本升级弃用方法替换

https://www.jianshu.com/p/603504408b7c

1.1 颜色定义变化

旧:

setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index)

cellStyle.setBottomBorderColor(HSSFColor.BLACK.getIndex());

cellStyle.setTopBorderColor(HSSFColor.BLACK.getIndex());

新:

setFillForegroundColor(IndexedColors.SKY_BLUE.index)

setBottomBorderColor(IndexedColors.BLACK.getIndex());

setTopBorderColor(IndexedColors.BLACK.getIndex());
1.2 获取单元格格式

旧:

cell.getCellType() < 2

CELL_TYPE_NUMERIC =0

CELL_TYPE_STRING = 1

CELL_TYPE_FORMULA = 2

Cell.CELL_TYPE_NUMERIC

新:

cell.getCellTypeEnum().NUMERIC == CellType.NUMERIC || cell.getCellTypeEnum().NUMERIC == CellType.STRING

CellType.NUMERIC
1.3 设置单元格格式

旧 :

row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);

新 :

row.getCell(0).setCellType(CellType.STRING);
1.4 设置单元格垂直居中样式

旧:

setAlignment(XSSFCellStyle.ALIGN_CENTER); // 居中

setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);//垂直

新:

setAlignment(HorizontalAlignment.CENTER); // 居中

setVerticalAlignment(VerticalAlignment.CENTER); //垂直
1.5 设置边框

旧:

setBorderBottom(HSSFCellStyle.BORDER_THIN); //下边框

setBorderLeft(HSSFCellStyle.BORDER_THIN);

setBorderRight(HSSFCellStyle.BORDER_THIN);

setBorderTop(HSSFCellStyle.BORDER_THIN);

新:

setBorderBottom(BorderStyle.THIN); //下边框

setBorderLeft(BorderStyle.THIN);

setBorderRight(BorderStyle.THIN);

setBorderTop(BorderStyle.THIN);
1.6 合并单元格

旧:

addMergedRegion(new CellRangeAddress(1, 1,(short) 0, (short) 0));// 起始行,结束行,起始列,结束列

新:

addMergedRegion(new Region(1, (short) 0, 1,(short) 0));// 起始行,起始列,结束行,结束列
1.7 设置字体加粗

旧:

setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);

新:

setBold(true)
1.8 字体颜色

旧:

setColor(HSSFColor.BLACK.index)

新:

setColor(IndexedColors.BLACK.getIndex())
1.9设置样式

旧:

setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);

新:

setFillPattern(FillPatternType.SOLID_FOREGROUND);

setFillForegroundColor(IndexedColors.SKY_BLUE.index);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值