poi3.x升级至4.x变化改造

  1. 字体加粗Bold
setBoldweight(HSSFFont.BOLDWEIGHT_BOLD)setBold(true)
  1. 边框BorderBottom
setBorderBottom(HSSFCellStyle.BORDER_THIN)setBorderBottom((short) 1)setBorderBottom(BorderStyle.THIN)
//其余边框设置同理使用BorderStyle
  1. 对齐方式Alignment和VerticalAlignment
setAlignment(HSSFCellStyle.ALIGN_CENTER)setAlignment(HorizontalAlignment.CENTER)

setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER)setVerticalAlignment(VerticalAlignment.CENTER)
  1. 填充样式FillPattern
setFillPattern((short) 2)setFillPattern(HSSFCellStyle.FINE_DOTS)setFillPattern(FillPatternType.FINE_DOTS)
  1. 填充背景颜色FillForegroundColor和FillBackgroundColor
setFillForegroundColor(HSSFColor.WHITE.index)setFillForegroundColor(IndexedColors.WHITE.index)

setFillBackgroundColor(HSSFColor.GREY_40_PERCENT.index)setFillBackgroundColor(IndexedColors.GREY_40_PERCENT.index)

  1. 线样式LineStyle
setLineStyle(CellStyle.BORDER_THIN)setLineStyle(BorderStyle.THIN.getCode())
  1. 单元格类型判断getCellType()
//返回不再是数值类型,而是CellType
HSSFCell.CELL_TYPE_NUMERIC0NUMERIC	//数字
HSSFCell.CELL_TYPE_STRING1STRING	//字符串
HSSFCell.CELL_TYPE_BOOLEAN2BOOLEAN	//Boolean
HSSFCell.CELL_TYPE_FORMULA3FORMULA	//公式
HSSFCell.CELL_TYPE_BLANK4BLANK	//空值
HSSFCell.CELL_TYPE_ERROR5ERROR	//异常
  1. 颜色数值:HSSFColor替换成IndexedColors
  2. 获取单元格MergedRegion,在4.x中Region已被删除
 Region r = sheet.getMergedRegionAt(i);CellRangeAddress r = sheet.getMergedRegion(i);
  1. 单元格参数CellRangeAddress
//开始行 结束行 开始列 结束列
CellRangeAddress(int firstRow, int lastRow, int firstCol, int lastCol)
注意:合并单元格时,当起始行等于结束行,且开始列等于结束列不允许合并,这个操作在3.x中是被允许的。已有合并不能再次进行合并。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值