You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Pooja MURJANI <po...@st.com> on 2006/06/01 08:24:09 UTC
Java.awt.Color to HSSFColor
Hello All,
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.
Can anyone help me out on this topic.
I will be really very thankful for this.
Regards,
Pooja
---------------------------------------------------------------------
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/
Re: Java.awt.Color to HSSFColor
Posted by Yegor Kozlov <ye...@dinom.ru>.
Hi
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(), (byte)color.getBlue());
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/