Home » Java » java – POI setting Cell Background to a Custom Hex Color-Exceptionshub

java – POI setting Cell Background to a Custom Hex Color-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

I am trying to set the Cell Background to a Custom Hex Color, when i try cs.setFillForegroundColor(color); java pops up an error
when i replace it by cs.setFillForegroundColor(color.getIndex()); the background shows a black background color.

Did they update java poi concerning this?: cs.setFillForegroundColor(color);
I tried setfillbackgroundColor also the same result appears. Please help

        String rgbS = "E4DFEC";
        byte[] rgbB = Hex.decodeHex(rgbS); // get byte array from hex string
        XSSFColor color = new XSSFColor(rgbB, null);
        cs.setFillForegroundColor(color.getIndex());

How to&Answers: