public void styleColor(Formatter out, String attr, Color color) { XSSFColor xSSFColor = (XSSFColor) color; if (color == null || xSSFColor.isAuto()) return; byte[] rgb = xSSFColor.getRgb(); if (rgb == null) { return; } out.format(" %s: #%02x%02x%02x;%n", attr, rgb[0], rgb[1], rgb[2]); } }
public void styleColor(Formatter out, String attr, Color color) { XSSFColor xSSFColor = (XSSFColor) color; if (color == null || xSSFColor.isAuto()) return; byte[] rgb = xSSFColor.getRgb(); if (rgb == null) { return; } out.format(" %s: #%02x%02x%02x;%n", attr, rgb[0], rgb[1], rgb[2]); } }
public static int[] getColorRGB(Color color){ int red = 0; int green = 0; int blue = 0; if (color instanceof HSSFColor) { HSSFColor hssfColor = (HSSFColor) color; short[] rgb = hssfColor.getTriplet(); red = rgb[0]; green = rgb[1]; blue = rgb[2]; }else if (color instanceof XSSFColor) { XSSFColor xssfColor = (XSSFColor) color; byte[] rgb = xssfColor.getRgb(); if(rgb != null) { red = (rgb[0] < 0) ? (rgb[0] + 256) : rgb[0]; green = (rgb[1] < 0) ? (rgb[1] + 256) : rgb[1]; blue = (rgb[2] < 0) ? (rgb[2] + 256) : rgb[2]; } } if(red != 0 || green != 0 || blue != 0){ return new int[] {red,green,blue}; }else return new int[] {255,255,255}; }
public static int getRGB(Color color){ int result = 0x00FFFFFF; int red = 0; int green = 0; int blue = 0; if (color instanceof HSSFColor) { HSSFColor hssfColor = (HSSFColor) color; short[] rgb = hssfColor.getTriplet(); red = rgb[0]; green = rgb[1]; blue = rgb[2]; }else if (color instanceof XSSFColor) { XSSFColor xssfColor = (XSSFColor) color; byte[] rgb = xssfColor.getRgb(); if(rgb != null) { red = (rgb[0] < 0) ? (rgb[0] + 256) : rgb[0]; green = (rgb[1] < 0) ? (rgb[1] + 256) : rgb[1]; blue = (rgb[2] < 0) ? (rgb[2] + 256) : rgb[2]; } } if(red != 0 || green != 0 || blue != 0){ result = new java.awt.Color(red, green, blue).getRGB(); } return result; }
public Color getAwtColor(XSSFColor color) { if(color == null){ return Color.BLACK; } if (color.getRgb() != null) { return new Color(ByteBuffer.wrap(color.getRgb()).getInt(), true); } else { if(color.getIndexed() == 64){ return Color.BLACK; } return getAwtColor(color.getTheme(), color.getTint()); } }
/** * set the color for the font in Standard Alpha Red Green Blue color value * * @param color - color to use */ public void setColor(XSSFColor color) { if(color == null) _ctFont.setColorArray(null); else { CTColor ctColor = _ctFont.sizeOfColorArray() == 0 ? _ctFont.addNewColor() : _ctFont.getColorArray(0); ctColor.setRgb(color.getRgb()); } }