Additional information after a bit of digging:
From XSSFCellStyle:
    public short getBorderBottom() {
        if(!_cellXf.getApplyBorder()) return BORDER_NONE;

        int idx = (int)_cellXf.getBorderId();
        CTBorder ct = _stylesSource.getBorderAt(idx).getCTBorder();
STBorderStyle.Enum ptrn = ct.isSetBottom() ? ct.getBottom().getStyle() : null;
        return ptrn == null ? BORDER_NONE : (short)(ptrn.intValue() - 1);
    }

The value for ptrn is:
"ct.getBottom().getStyle()"     (pending)
    _int    5
    _string    "dotted" (id=264)

Which does seem at odds with CellStyle:
    /**
     * dot border
     */

    public final static short BORDER_HAIR = 0x4;

    /**
     * Thick border
     */

    public final static short BORDER_THICK = 0x5;

    /**
     * double-line border
     */

    public final static short BORDER_DOUBLE = 0x6;

    /**
     * hair-line border
     */

    public final static short BORDER_DOTTED = 0x7;

But then I noticed the comments on the values in CellStyle (copied verbatim above).

Definitely looks broken to me.

Jim


On 14/04/2013 21:02, Jim Talbut wrote:
Hi,

I have a unit test that causes the creation of an Excel workbook containing a single sheet, with a single columns containing 12 cells.
Each cell was created with a border style going all the way around.
My code has to translate from the source borders to POI/Excel - so I have the following cells/borders even though they don't all exist in POI/Excel:
Solid Black Thin
Solid Black Medium
Solid Black Thick
Dotted Black Thin
Dotted Black Medium
Dotted Black Thick
Dashed Black Thin
Dashed Black Medium
Dashed Black Thick
Double Black Thin
Double Black Medium
Double Black Thick

My issue is that for the XLSX file I'm getting a value of 4 returned by style.getBorder*() when I'm expecting a value of 7 (BORDER_DOTTED). For XLS I'm getting the expected value; in POI 3.8 I got the expected value. I don't want to send an unannounced attachment, but I can send you the workbook if that would help.

Is this a bug in POI 3.9?
Does it affect anything other than the reading of one border style in XLSX files?

Thanks.

Jim


In my unit test I have:
private void assertSingleBorder( int row, String border, short expected, short actual ) { // assertEquals( "Row " + row + ", border \"" + border + "\": ", expected, actual );
        if( expected != actual ) {
System.out.println( "Row " + row + ", border \"" + border + "\": " + actual + " != " + expected );
        }
    }


private void assertBorder( Sheet sheet, int row, int col, short bottom, short left, short right, short top ) {

        Cell cell = sheet.getRow(row).getCell(col);
        CellStyle style = cell.getCellStyle();

assertSingleBorder( row, "bottom", bottom, style.getBorderBottom() );
        assertSingleBorder( row, "left", left, style.getBorderLeft() );
assertSingleBorder( row, "right", right, style.getBorderRight() );
        assertSingleBorder( row, "top", top, style.getBorderTop() );
    }

...
assertBorder( sheet, i++, 0, CellStyle.BORDER_THIN, CellStyle.BORDER_THIN, CellStyle.BORDER_THIN, CellStyle.BORDER_THIN ); assertBorder( sheet, i++, 0, CellStyle.BORDER_MEDIUM, CellStyle.BORDER_MEDIUM, CellStyle.BORDER_MEDIUM, CellStyle.BORDER_MEDIUM ); assertBorder( sheet, i++, 0, CellStyle.BORDER_THICK, CellStyle.BORDER_THICK, CellStyle.BORDER_THICK, CellStyle.BORDER_THICK );

assertBorder( sheet, i++, 0, CellStyle.BORDER_DOTTED, CellStyle.BORDER_DOTTED, CellStyle.BORDER_DOTTED, CellStyle.BORDER_DOTTED ); assertBorder( sheet, i++, 0, CellStyle.BORDER_DOTTED, CellStyle.BORDER_DOTTED, CellStyle.BORDER_DOTTED, CellStyle.BORDER_DOTTED ); assertBorder( sheet, i++, 0, CellStyle.BORDER_DOTTED, CellStyle.BORDER_DOTTED, CellStyle.BORDER_DOTTED, CellStyle.BORDER_DOTTED );

assertBorder( sheet, i++, 0, CellStyle.BORDER_DASHED, CellStyle.BORDER_DASHED, CellStyle.BORDER_DASHED, CellStyle.BORDER_DASHED ); assertBorder( sheet, i++, 0, CellStyle.BORDER_MEDIUM_DASHED, CellStyle.BORDER_MEDIUM_DASHED, CellStyle.BORDER_MEDIUM_DASHED, CellStyle.BORDER_MEDIUM_DASHED ); assertBorder( sheet, i++, 0, CellStyle.BORDER_MEDIUM_DASHED, CellStyle.BORDER_MEDIUM_DASHED, CellStyle.BORDER_MEDIUM_DASHED, CellStyle.BORDER_MEDIUM_DASHED );

assertBorder( sheet, i++, 0, CellStyle.BORDER_DOUBLE, CellStyle.BORDER_DOUBLE, CellStyle.BORDER_DOUBLE, CellStyle.BORDER_DOUBLE ); assertBorder( sheet, i++, 0, CellStyle.BORDER_DOUBLE, CellStyle.BORDER_DOUBLE, CellStyle.BORDER_DOUBLE, CellStyle.BORDER_DOUBLE ); assertBorder( sheet, i++, 0, CellStyle.BORDER_DOUBLE, CellStyle.BORDER_DOUBLE, CellStyle.BORDER_DOUBLE, CellStyle.BORDER_DOUBLE );
...



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to