The XSSFSheet.getColumnStyle behaves differently than the corresponding method on HSSFSheet & what the API doc for Sheet says it should do. The javadoc for org.apache.poi.ss.usermodel.Sheet states for getColumnStyle(int): "Returns the CellStyle that applies to the given (0 based) column, or null if no style has been set for that column" For XSSFSheet, however, if no cell style has been set for the column, then a new style is created and returned. HSSFSheet conforms to the API doc, whereas XSSFSheet does not. Reasoning/Why this causes problems: Essentially, I want to use a Excel file as a "template" (though not a xlt/xltx, just a normal xls/xlsx) and write to a new spreadsheet, just taking the formatting from the template. If the "template" spreadsheet contains cell formatting, I want to preserve that formatting. In order to do this, I need to check if there is a style applied on the existing cell, then row, then column - although I guess the row then column ordering doesn't matter. According to the API, I should just be able to check if, in the template, the "template"'s Sheet.getColumnStyle(col) returns null. However if it came from an XLSX format, then the XSSFSheet will always return a style, which I then have to compare against what is returned from Workbook.createCellStyle to see if this is different from the default before working out if there really was a cell style applied for this column. Also, it just breaks the API contract doesn't it?
Sorry, my mistake. Constructed a second bug after I got an error back from bugzilla while trying to create the first time. Second one (56525) contains a touch more info, so closing this one as a dup. *** This bug has been marked as a duplicate of bug 56525 ***