poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yegor Kozlov <ye...@dinom.ru>
Subject Re: Java.awt.Color to HSSFColor
Date Fri, 02 Jun 2006 11:57:36 GMT

In Excel you can use only a limited set of colors which is defined by Excel color palette.
Standard colors are included in org.apache.poi.hssf.util.HSSFColor.

If you want to use your own color you need select a color which is not used and redefine it:

  java.awt.Color color; //custom color

  HSSFPalette palette = workbook.getCustomPalette();
  HSSFColor hssfColor = palette.findColor((byte)color.getRed(), (byte)color.getGreen(), (byte)color.getBlue());
  if (hssfColor == null ){
      palette.setColorAtIndex(HSSFColor.LAVENDER.index, (byte)color.getRed(), (byte)color.getGreen(),
      hssfColor = palette.getColor(HSSFColor.LAVENDER.index);

Regards, Yegor

PM> Hello All,

PM> I am a new-bie in using apache HSSF API for generating a excel sheet by java code.
I am facing problem in converting java.awt.Color to org.apache.poi.hssf.util.HSSFColor.

PM> Can anyone help me out on this topic. 

PM> I will be really very thankful for this.

PM> Regards,
PM> Pooja

PM> ---------------------------------------------------------------------
PM> To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
PM> Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
PM> The Apache Jakarta POI Project: http://jakarta.apache.org/poi/

To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/

View raw message