This project is read-only.

addcolor error System.Exception: Could not Find free color index

Dec 14, 2009 at 12:45 PM

Why if i use

Dim lColor As HSSFColor

lPaleta = lworkbook.GetCustomPalette
lColorF = lPaleta.FindColor(lRed, lGreen, lBlue)
If lColorF Is Nothing Then
'color no creado en paleta, crearlo
  lColorF = lPaleta.AddColor(lRed, lGreen, lBlue)
End If

it throws:

System.Exception: Could not Find free color index

?

 

Coordinator
Dec 15, 2009 at 8:24 AM

What are the value of lRed, lGreen, lBlue? Do you use code similar to HSSFColor.Red.index?

Dec 15, 2009 at 9:30 AM
Edited Dec 15, 2009 at 3:13 PM
lred=0
lgreen=192
lblue=255

I don't understand the second question. What's the code similar to HSSFColor.Red.Index?

 

Are there any method of putting an RGB color directly (specifying red, color and blue components) to a cell without using the palette ?

 

Mar 12, 2010 at 4:01 PM
Edited Mar 12, 2010 at 4:03 PM

Hi,

Same error here:

HSSFPalette palette = workbook.GetCustomPalette();
HSSFColor radientColor = palette.AddColor( 127, 186, 0 );  // System.Exception: Could not Find free color index
...
HSSFCellStyle title = workbook.CreateCellStyle();
HSSFFont titleFont = workbook.CreateFont();

titleFont.Color =  radientColor.GetIndex();

title.SetFont( titleFont );

 

Mar 12, 2010 at 5:06 PM

Apparently, there is no possible way to add custom colors the OOP way.

I have checked the library with .NET Reflector and the existing colors are embedded in the library and are retrieved from that collection.

We'll have to modify the source code, recompile and use that custom build.