- 字体加粗Bold
setBoldweight(HSSFFont.BOLDWEIGHT_BOLD)
↓
setBold(true)
- 边框BorderBottom
setBorderBottom(HSSFCellStyle.BORDER_THIN) 或 setBorderBottom((short) 1)
↓
setBorderBottom(BorderStyle.THIN)
- 对齐方式Alignment和VerticalAlignment
setAlignment(HSSFCellStyle.ALIGN_CENTER)
↓
setAlignment(HorizontalAlignment.CENTER)
setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER)
↓
setVerticalAlignment(VerticalAlignment.CENTER)
- 填充样式FillPattern
setFillPattern((short) 2) 或 setFillPattern(HSSFCellStyle.FINE_DOTS)
↓
setFillPattern(FillPatternType.FINE_DOTS)
- 填充背景颜色FillForegroundColor和FillBackgroundColor
setFillForegroundColor(HSSFColor.WHITE.index)
↓
setFillForegroundColor(IndexedColors.WHITE.index)
setFillBackgroundColor(HSSFColor.GREY_40_PERCENT.index)
↓
setFillBackgroundColor(IndexedColors.GREY_40_PERCENT.index)
- 线样式LineStyle
setLineStyle(CellStyle.BORDER_THIN)
↓
setLineStyle(BorderStyle.THIN.getCode())
- 单元格类型判断getCellType()
HSSFCell.CELL_TYPE_NUMERIC 或 0 → NUMERIC
HSSFCell.CELL_TYPE_STRING 或 1 → STRING
HSSFCell.CELL_TYPE_BOOLEAN 或 2 → BOOLEAN
HSSFCell.CELL_TYPE_FORMULA 或 3 → FORMULA
HSSFCell.CELL_TYPE_BLANK 或 4 → BLANK
HSSFCell.CELL_TYPE_ERROR 或 5 → ERROR
- 颜色数值:HSSFColor替换成IndexedColors
- 获取单元格MergedRegion,在4.x中Region已被删除
Region r = sheet.getMergedRegionAt(i);
↓
CellRangeAddress r = sheet.getMergedRegion(i);
- 单元格参数CellRangeAddress
CellRangeAddress(int firstRow, int lastRow, int firstCol, int lastCol)
注意:合并单元格时,当起始行等于结束行,且开始列等于结束列不允许合并,这个操作在3.x中是被允许的。已有合并不能再次进行合并。