byte red = (byte) color.getRed();
byte green = (byte) color.getGreen();
byte blue = (byte) color.getBlue();
HSSFPalette palette = workbook.getCustomPalette();
HSSFColor c = palette.findSimilarColor(red, green, blue);
if (c == null) {
try {
c = palette.addColor(red, green, blue);
} catch (RuntimeException e) {
c = palette.findSimilarColor(red, green, blue);