java borderstyle_java – Apache POI 3.15:RegionUtil和BorderStyle?

我使用的是Apache POI 3.15.

我最近切换到最新版本,我们现在有一些不赞成的方法,有’短’边框样式,’短’对齐…

对于这些已弃用的方法,我们有使用Enum参数的新方法(如BorderStyle,Horizo​​ntalAlignment,FillPatternType …).

没关系对我来说.

现在,我还使用RegionUtil为合并区域添加一些样式.

但RegionUtil似乎使用旧的“短”风格.

protected static void addMergedRegion(Sheet sheet, int iRowMin, int iRowMax, int iColMin, int iColMax) {

CellRangeAddress cellZone = new CellRangeAddress(iRowMin, iRowMax, iColMin, iColMax);

sheet.addMergedRegion(cellZone);

Cell cell = sheet.getRow(iRowMin).getCell(iColMin);

if (cell != null) {

RegionUtil.setBorderBottom(cell.getCellStyle().getBorderBottomEnum().getCode(), cellZone, sheet);

RegionUtil.setBorderTop(cell.getCellStyle().getBorderTopEnum().getCode(), cellZone, sheet);

RegionUtil.setBorderLeft(cell.getCellStyle().getBorderLeftEnum().getCode(), cellZone, sheet);

RegionUtil.setBorderRight(cell.getCellStyle().getBorderRightEnum().getCode(), cellZone, sheet);

RegionUtil.setBottomBorderColor(cell.getCellStyle().getBottomBorderColor(), cellZone, sheet);

RegionUtil.setTopBorderColor(cell.getCellStyle().getTopBorderColor(), cellZone, sheet);

RegionUtil.setLeftBorderColor(cell.getCellStyle().getLeftBorderColor(), cellZone, sheet);

RegionUtil.setRightBorderColor(cell.getCellStyle().getRightBorderColor(), cellZone, sheet);

}

}

但我在我的日志中发现了一些行:

BorderStyle short usage

我在CellUtil类中找到了这一行的起源:

private static BorderStyle getBorderStyle(Map properties, String name) {

Object value = properties.get(name);

BorderStyle border;

if (value instanceof BorderStyle) {

border = (BorderStyle) value;

}

// @deprecated 3.15 beta 2. getBorderStyle will only work on BorderStyle enums instead of codes in the future.

else if (value instanceof Short) {

if (log.check(POILogger.WARN)) {

log.log(POILogger.WARN, "Deprecation warning: CellUtil properties map uses Short values for "

+ name + ". Should use BorderStyle enums instead.");

}

System.out.println("BorderStyle short usage");

short code = ((Short) value).shortValue();

border = BorderStyle.valueOf(code);

}

else if (value == null) {

border = BorderStyle.NONE;

}

else {

throw new RuntimeException("Unexpected border style class. Must be BorderStyle or Short (deprecated).");

}

return border;

}

您是否有使用Enum样式为合并区域制作边框的解决方案?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值