poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 56524] New: XSSFSheet.getColumnStyle doesn't conform to Sheet.getColumnStyle API doc
Date Wed, 14 May 2014 17:30:13 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=56524

            Bug ID: 56524
           Summary: XSSFSheet.getColumnStyle doesn't conform to
                    Sheet.getColumnStyle API doc
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: tmeagher@lavastorm.com

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?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message