poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dcoales <david.coa...@accipia.com>
Subject XSSF convert short from getLeftBorderColor to Color object
Date Tue, 12 Oct 2010 10:20:33 GMT


I'm writing a program to create an html representation of a spreadsheet.  I
have reached the point where I want to create the CSS for a cell to set its
border colors.  

If my understanding is correct there is no generic way to do this using the
ss usermodel objects.  I have to first use 'instanceof' to detect whether I
have an XSSFCellStyle or HSSFCellStyle (in my case it could be either) and
then take a different approach in each case as shown below. 

With an HSSF spreadsheet it seems very straightforward.  For example I call
CellStyle.getLeftBorderColor which returns a short and then I use the
Palette from the workbook to convert the short into a Color object which I
can then use to create an RGB code to use in my CSS.

Things seem more complicated in XSSF.  The same methods exist but I wouldn't
know how to convert the short that is returned into anything useful as the
XSSFWorkbook doesn't have method to return a Palette.  Instead I believe I
need to use the new method CellStyle.getBorderColor(BorderSide.Left) which
returns an XSSFColor.

Have I understood this correctly or is there in fact a way to do this using
the generic usermodel CellStyle and Workbook objects without caring whether
the underlying instances are HSSF  or XSSF.

Many thanks for your help.

View this message in context: http://apache-poi.1045710.n5.nabble.com/XSSF-convert-short-from-getLeftBorderColor-to-Color-object-tp3208692p3208692.html
Sent from the POI - User mailing list archive at Nabble.com.

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

View raw message