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

--- Comment #2 from Javen O'Neal <one...@apache.org> ---
Correct. XSSFSheet#getColumnStyle returns the default column style rather than
returning null.
As a workaround, you could check of the index of the returned style == 0.
Unfortunately, there is a setDefaultColumnStyle method in the Sheet interface
but not a getDefaultColumnStyle method (though ColumnHelper offers something
similar). Furthermore, I'm unsure if XSSFSheet.getColumnStyle on an unstyled
column returns the correct default column style after setDefaultColumnStyle has
been called.


> /**
>  * Returns the CellStyle that applies to the given
>  *  (0 based) column, or null if no style has been
>  *  set for that column
>  */
> @Override
> public CellStyle getColumnStyle(int column) {
>     int idx = columnHelper.getColDefaultStyle(column);
>     return getWorkbook().getCellStyleAt((short)(idx == -1 ? 0 : idx));
> }

> /**
>  * Returns the HSSFCellStyle that applies to the given
>  * (0 based) column, or null if no style has been
>  * set for that column
>  */
> @Override
> public HSSFCellStyle getColumnStyle(int column) {
>     short styleIndex = _sheet.getXFIndexForColAt((short) column);
> 
>     if (styleIndex == 0xf) {
>         // None set
>         return null;
>     }
> 
>     ExtendedFormatRecord xf = _book.getExFormatAt(styleIndex);
>     return new HSSFCellStyle(styleIndex, xf, _book);
> }

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

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

Reply via email to