Package org.zkoss.poi.hssf.util

Examples of org.zkoss.poi.hssf.util.HSSFColor


      return getHSSFRGBString((HSSFCell)cell, font.getColor());
    }
  }
 
  private static String getHSSFRGBString(HSSFCell cell, short index) {
    final HSSFColor color = ((HSSFCellStyle)cell.getCellStyle()).getFontColorColor();
    return HSSFColorToHTML((HSSFWorkbook) cell.getSheet().getWorkbook(), color);
  }
View Full Code Here


    }
    return   "#"+ toHex(argb[0])+ toHex(argb[1])+ toHex(argb[2]);
  }
  private static String indexToHSSFRGB(HSSFWorkbook book, int index) {
    HSSFPalette palette = book.getCustomPalette();
    HSSFColor color = null;
    if (palette != null) {
      color = palette.getColor(index);
    }
    short[] triplet = null;
    if (color != null)
      triplet =  color.getTriplet();
    else {
      final Map<Integer, HSSFColor> colors = HSSFColor.getIndexHash();
      color = colors.get(Integer.valueOf(index));
      if (color != null)
        triplet = color.getTriplet();
    }
    return triplet == null ? null :
      HSSFColor.AUTOMATIC.getInstance().equals(color) ? AUTO_COLOR : tripletToHTML(triplet);
  }
View Full Code Here

    short blue = Short.parseShort(color.substring(5), 16); //blue
    byte r = (byte)Math.abs((byte)red);
    byte g = (byte)Math.abs((byte)green);
    byte b = (byte)Math.abs((byte)blue);
   
    HSSFColor pcolor = palette.findColor(r, g, b);
    if (pcolor != null) { //find default palette
      return pcolor.getIndex();
    } else {
      final Hashtable<short[], HSSFColor> colors = HSSFColor.getRgbHash();
      HSSFColor tcolor = colors.get(new short[] {red, green, blue});
      if (tcolor != null)
        return tcolor.getIndex();
      else {
        try {
          HSSFColor ncolor = palette.addColor(r, g, b);
          return ncolor.getIndex();
        } catch (RuntimeException ex) {
          //return similar color if can't add new color to palette
          /*
           * TODO: find a better solution for fix this issue
           *
 
View Full Code Here

    byte b = triplet[2];
    short red = (short) (r & 0xff);
    short green = (short) (g & 0xff);
    short blue = (short) (b & 0xff);
    HSSFPalette palette = book.getCustomPalette();
    HSSFColor pcolor = palette != null ? palette.findColor(r, g, b) : null;
    if (pcolor != null) { //find default palette
      return pcolor;
    } else {
      final Hashtable<short[], HSSFColor> colors = HSSFColor.getRgbHash();
      HSSFColor tcolor = colors.get(new short[] {red, green, blue});
      if (tcolor != null)
        return tcolor;
      else {
        try {
          HSSFColor ncolor = palette.addColor(r, g, b);
          return ncolor;
        } catch (RuntimeException ex) {
          //try to create a fullcolor if not a built in palette color
          FullColorExt fullColor = new FullColorExt(red, green, blue);
          return new HSSFColorExt(fullColor);
View Full Code Here

TOP

Related Classes of org.zkoss.poi.hssf.util.HSSFColor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.