2016-09-29 15 views
4

私はApache POI 3.15を使用します。 私は最近、最新のバージョンに切り替えましたが、現在、「短い」境界線スタイル、「短い」整列の廃止されたメソッドがあります。 これらの非推奨のメソッドに対しては、BorderStyle、Horizo​​ntalAlignment、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スタイルを使用して結合された領域の境界線を作成するソリューションはありますか?

+2

私はPOI Bugzillaにバグをオープンすることをお勧めします。うまくいけば、Javen(POI enum guru)は 'RegionUtil'を修正できます! – Gagravarr

+0

bugzillaアプリケーションにバグを提出します。ここにリンクしてください:https://bz.apache.org/bugzilla/show_bug.cgi?id=60187 –

答えて

3

あなたは、Apache POI 3.16ベータ1またはそれ以降、または作られた今の毎晩/ SVNトランク/ Gitのヘッドビルドを必要とする、これが唯一のr1762856

で固定し、3.15よりはApache POIの新しいバージョンを使用する必要がありますafter 20160930

+0

私は同じ問題を抱えています。私は3.16beta1と3.16beta2の両方を試しました。しかし、それは私にとってはうまくいかなかった。 –