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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to