示例#1
0
 public void styleColor(Formatter out, String attr, Color color) {
   if (color == null) {
     return;
   }
   HSSFColor hSSFColor = (HSSFColor) color;
   short[] rgb = hSSFColor.getTriplet();
   out.format("  %s: #%02x%02x%02x; %n", attr, rgb[0], rgb[1], rgb[2]);
 }
示例#2
0
 private void styleColor(Formatter out, String attr, short index) {
   HSSFColor color = colors.getColor(index);
   if (index == HSSF_AUTO.getIndex() || color == null) {
     out.format("  /* %s: index = %d */%n", attr, index);
   } else {
     short[] rgb = color.getTriplet();
     out.format("  %s: #%02x%02x%02x; /* index = %d */%n", attr, rgb[0], rgb[1], rgb[2], index);
   }
 }
 private static final Color getAWTColor(HSSFColor clr) {
   short[] rgb = clr.getTriplet();
   return new Color(rgb[0], rgb[1], rgb[2]);
 }
示例#4
-1
 public static ColorInfo excelColor2UOF(Color color) {
   if (color == null) {
     return null;
   }
   ColorInfo ci = null;
   if (color instanceof XSSFColor) { // .xlsx
     XSSFColor xc = (XSSFColor) color;
     byte[] b = xc.getRgb();
     if (b != null) { // 一定是argb
       ci = ColorInfo.fromARGB(b[0], b[1], b[2], b[3]);
     }
   } else if (color instanceof HSSFColor) { // .xls
     HSSFColor hc = (HSSFColor) color;
     short[] s = hc.getTriplet(); // 一定是rgb
     if (s != null) {
       ci = ColorInfo.fromARGB(s[0], s[1], s[2]);
     }
   }
   return ci;
 }