You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by John <ji...@foxmail.com> on 2015/11/18 04:46:27 UTC

回复:Correctly getting the color of an XSSFCellStyle

Hi Brian,
Maybe you can try this.
public static byte[] getCellFontColor(XSSFCell cell) {
    XSSFCellStyle cellStyle = cell.getCellStyle();
    if(null == cellStyle) {
        return null;
    }
    List<CTColor> colorList = cellStyle.getFont().getCTFont().getColorList();
    if (colorList.size() == 1) {
        CTColor ctColor = colorList.get(0);
        return ctColor.getRgb();
    }
    return null;
}public static byte[] getCellBackgroundColor(XSSFCell cell) {
    XSSFCellStyle cellStyle = cell.getCellStyle();
    if(null == cellStyle) {
        return null;
    }
    XSSFColor backgroundColor = cellStyle.getFillForegroundColorColor();
    if(null == backgroundColor) {
        return null;
    }
    return backgroundColor.getRgb();
}




------------------ 原始邮件 ------------------
发件人: "Brian Milnes";<br...@xbrlcloud.com>;
发送时间: 2015年11月18日(星期三) 凌晨1:43
收件人: "user"<us...@poi.apache.org>; 

主题: Correctly getting the color of an XSSFCellStyle



I've got spreadsheet that has multiple gray cells which are blank
and I'd like to leave blank, and multiple white cells which are blank and I
would like to fill them.

I want to recognize them and not fill them but I can't get the logic right
or I have an issue with 3.13.

 They both can end up with a
SOLID_FOREGROUND fill,
getFillForegroundColor of 0
and getFillFillForgroundColor of ARGB of -1 -1 -1 -1.

 What is the correct way to differentiate empty white versus gray cells?

 Thanks, Brian

Re: Correctly getting the color of an XSSFCellStyle

Posted by Brian Milnes <br...@xbrlcloud.com>.
John,

 Alas that does not correctly work either. I'm suspecting a bug.

Thanks, Brian


On Tue, Nov 17, 2015 at 7:46 PM, John <ji...@foxmail.com> wrote:

> Hi Brian,
> Maybe you can try this.
> public static byte[] getCellFontColor(XSSFCell cell) {
>     XSSFCellStyle cellStyle = cell.getCellStyle();
>     if(null == cellStyle) {
>         return null;
>     }
>     List<CTColor> colorList =
> cellStyle.getFont().getCTFont().getColorList();
>     if (colorList.size() == 1) {
>         CTColor ctColor = colorList.get(0);
>         return ctColor.getRgb();
>     }
>     return null;
> }public static byte[] getCellBackgroundColor(XSSFCell cell) {
>     XSSFCellStyle cellStyle = cell.getCellStyle();
>     if(null == cellStyle) {
>         return null;
>     }
>     XSSFColor backgroundColor = cellStyle.getFillForegroundColorColor();
>     if(null == backgroundColor) {
>         return null;
>     }
>     return backgroundColor.getRgb();
> }
>
>
>
>
> ------------------ 原始邮件 ------------------
> 发件人: "Brian Milnes";<br...@xbrlcloud.com>;
> 发送时间: 2015年11月18日(星期三) 凌晨1:43
> 收件人: "user"<us...@poi.apache.org>;
>
> 主题: Correctly getting the color of an XSSFCellStyle
>
>
>
> I've got spreadsheet that has multiple gray cells which are blank
> and I'd like to leave blank, and multiple white cells which are blank and I
> would like to fill them.
>
> I want to recognize them and not fill them but I can't get the logic right
> or I have an issue with 3.13.
>
>  They both can end up with a
> SOLID_FOREGROUND fill,
> getFillForegroundColor of 0
> and getFillFillForgroundColor of ARGB of -1 -1 -1 -1.
>
>  What is the correct way to differentiate empty white versus gray cells?
>
>  Thanks, Brian
>



-- 
Brian Milnes
CIO XBRL Cloud
206 406 7576