You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by David Thielen <da...@windward.net> on 2004/12/08 20:03:14 UTC

exception adding a color

Hi;

 

When I go to add a color, the first time, I get this exception:

 

java.lang.RuntimeException: Could not find free color index

      at
org.apache.poi.hssf.usermodel.HSSFPalette.addColor(HSSFPalette.java:140)

      at
net.windward.format.xls.PoiUtilities.findOrCreateColor(PoiUtilities.java:77)

 

My code is:

      public static short findOrCreateColor(HSSFWorkbook wb, byte red, byte
green, byte blue) {

            HSSFPalette palette = wb.getCustomPalette();

            HSSFColor ssClr = palette.findColor(red, green, blue);

            if (ssClr != null)

                  return ssClr.getIndex();

            return palette.addColor(red, green, blue).getIndex();

}

 

Any ideas?

 

Thanks - dave