java - Apache POI - Negative color values -
i'm trying write code outputs color of cells in excel sheet, when calling method getfillbackgroundcolor, gives me 3 negative values. i'm wondering, there somehow related rgb numbers? code wrote:
cellstyle style = currentcell2.getcellstyle(); color color = style.getfillbackgroundcolorcolor(); if (color != null) { byte[] clr = ((xssfcolor) color).getrgb(); system.out.print("( "); (int k = 0; k<clr.length; k++) { system.out.print(clr[k]+" "); } system.out.print(" )"); }
a byte signed in java. may unsigned value doing binary and 0xff:
... system.out.print((clr[k] & 0xff) + " "); ... but if color color = style.getfillbackgroundcolorcolor(); one possible fill color out of two.
excel cells may have pattern filling , fillbackgroundcolorcolor color behind pattern , fillforegroundcolorcolor color of pattern. default filled cells have solid pattern , need fillforegroundcolorcolor because fillbackgroundcolorcolor covered pattern.
so believe need color color = style.getfillforegroundcolorcolor();.
Comments
Post a Comment