--- src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (revision 1765534) +++ src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (working copy) @@ -959,7 +959,10 @@ @Override public CellStyle getColumnStyle(int column) { int idx = columnHelper.getColDefaultStyle(column); - return getWorkbook().getCellStyleAt((short)(idx == -1 ? 0 : idx)); + if (idx == -1) { + return null; + } + return getWorkbook().getCellStyleAt(idx); } /** --- src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (revision 1765534) +++ src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (working copy) @@ -1109,12 +1109,12 @@ CellStyle blueStyle = wb.createCellStyle(); blueStyle.setFillForegroundColor(IndexedColors.AQUA.getIndex()); - blueStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); + blueStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); assertEquals(1, blueStyle.getIndex()); CellStyle pinkStyle = wb.createCellStyle(); pinkStyle.setFillForegroundColor(IndexedColors.PINK.getIndex()); - pinkStyle.setFillPattern(CellStyle.SOLID_FOREGROUND); + pinkStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); assertEquals(2, pinkStyle.getIndex()); // Starts empty @@ -1134,9 +1134,9 @@ assertEquals(1, s.getCTWorksheet().sizeOfColsArray()); assertEquals(0, cols.sizeOfColArray()); - assertEquals(defaultStyle, s.getColumnStyle(0)); - assertEquals(defaultStyle, s.getColumnStyle(2)); - assertEquals(defaultStyle, s.getColumnStyle(3)); + assertNull(s.getColumnStyle(0)); + assertNull(s.getColumnStyle(2)); + assertNull(s.getColumnStyle(3)); // Apply the styles @@ -1145,7 +1145,7 @@ // Check assertEquals(pinkStyle, s.getColumnStyle(0)); - assertEquals(defaultStyle, s.getColumnStyle(2)); + assertNull(s.getColumnStyle(2)); assertEquals(blueStyle, s.getColumnStyle(3)); assertEquals(1, s.getCTWorksheet().sizeOfColsArray()); @@ -1169,7 +1169,7 @@ pinkStyle = wbBack.getCellStyleAt(pinkStyle.getIndex()); assertEquals(pinkStyle, s.getColumnStyle(0)); - assertEquals(defaultStyle, s.getColumnStyle(2)); + assertNull(s.getColumnStyle(2)); assertEquals(blueStyle, s.getColumnStyle(3)); wbBack.close(); }