私はApache POI 3.15を使用します。 私は最近、最新のバージョンに切り替えましたが、現在、「短い」境界線スタイル、「短い」整列の廃止されたメソッドがあります。 これらの非推奨のメソッドに対しては、BorderStyle、HorizontalAlignment、FillPatternTypeなどの新しいメソッドがあります。 )。 それは私にとっては大丈夫です。Apache POI 3.15:RegionUtilとBorderStyle?
ここでも、私はRegionUtilを使ってマージされたリージョンのスタイルを設定します。 しかし、RegionUtilは古い「短い」スタイルを使用しているようです。
ここに私のコード(https://stackoverflow.com/a/23619827/502040からインスピレーションを得たが、廃止予定のメソッドを使用せずに):
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短い用法
を私はCellUtilクラスでこのラインの起源を見つけました:
private static BorderStyle getBorderStyle(Map<String, Object> 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スタイルを使用して結合された領域の境界線を作成するソリューションはありますか?
私はPOI Bugzillaにバグをオープンすることをお勧めします。うまくいけば、Javen(POI enum guru)は 'RegionUtil'を修正できます! – Gagravarr
bugzillaアプリケーションにバグを提出します。ここにリンクしてください:https://bz.apache.org/bugzilla/show_bug.cgi?id=60187 –