poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 56774] New: Inability to set custom colors in Custom Formatting Pattern Formatting
Date Sun, 27 Jul 2014 20:44:14 GMT

            Bug ID: 56774
           Summary: Inability to set custom colors in Custom Formatting
                    Pattern Formatting
           Product: POI
           Version: 3.10
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: bhamue@gmail.com

Under XSSF there is no way of setting custom colors when using
ConditionalFormatting. I believe in the HSSF side we can alter the pallet to
replace an indexed color with a custom collor and then use that but on XSSF
side this is not possible. 

Would it be possible to add the following funtion to XSSFPatternFormatting
class. I tried this hack and seems to be working fine.

    public void setFillBackgroundColor(java.awt.Color clr){
        CTPatternFill ptrn = _fill.isSetPatternFill() ? _fill.getPatternFill()
: _fill.addNewPatternFill();
        CTColor bgColor = CTColor.Factory.newInstance();
        bgColor.setRgb(new byte[]{(byte)clr.getRed(), (byte)clr.getGreen(),


With this method, I can set a custom color as 

        ConditionalFormattingRule colorHigh =
sheetCF.createConditionalFormattingRule(ComparisonOperator.GT, "H$48");
        XSSFPatternFormatting highFill =
        highFill.setFillBackgroundColor(new java.awt.Color(198, 239, 206));

You are receiving this mail because:
You are the assignee for the bug.

To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org

View raw message