You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2014/05/14 19:32:01 UTC

[Bug 56525] New: XSSFSheet.getColumnStyle doesn't conform to Sheet.getColumnStyle API doc

https://issues.apache.org/bugzilla/show_bug.cgi?id=56525

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

NOTE: Haven't tested against newest version (or maybe I did but can't recall),
but couldn't find anything in changelog to indicate it's been fixed.

Problem:
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


[Bug 56525] XSSFSheet.getColumnStyle doesn't conform to Sheet.getColumnStyle API doc

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=56525

--- Comment #1 from Tim Meagher <tm...@lavastorm.com> ---
*** Bug 56524 has been marked as a duplicate of this bug. ***

-- 
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