Пример #1
-1
    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]);
    }
Пример #2
-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;
 }