Thanks Yegor,

That basically confirms what I thought.  Hopefully a generic getColor method 
that returns a generic Color object which has a get RGB method will be 
introduced in the future.

Cheers,
David

From: Yegor Kozlov [via Apache POI] 
[mailto:[email protected]]
Sent: 12 October 2010 13:06
To: David Coales
Subject: Re: XSSF convert short from getLeftBorderColor to Color object

  Look at
https://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java

Regards,
Yegor

> Hi,
>
> 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.
>
> David


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden 
email]</user/SendEmail.jtp?type=node&node=3208791&i=0>
For additional commands, e-mail: [hidden 
email]</user/SendEmail.jtp?type=node&node=3208791&i=1>


________________________________
View message @ 
http://apache-poi.1045710.n5.nabble.com/XSSF-convert-short-from-getLeftBorderColor-to-Color-object-tp3208692p3208791.html
To unsubscribe from XSSF convert short from getLeftBorderColor to Color object, 
click 
here<http://apache-poi.1045710.n5.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_code&node=3208692&code=ZGF2aWQuY29hbGVzQGFjY2lwaWEuY29tfDMyMDg2OTJ8MjE0MjU3NDU3MA==>.


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

Reply via email to