Package org.apache.poi.xssf.usermodel

Examples of org.apache.poi.xssf.usermodel.XSSFColor


        final XSSFCellStyle xssfCellStyle = (XSSFCellStyle) hssfCellStyle;
        if (BorderStyle.NONE.equals(bg.getBottom().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderBottom(styleKey.getBorderStrokeBottom());
          xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.BOTTOM,
              new XSSFColor(styleKey.getExtendedColorBottom()));
        }
        if (BorderStyle.NONE.equals(bg.getTop().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderTop(styleKey.getBorderStrokeTop());
          xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.TOP,
              new XSSFColor(styleKey.getExtendedColorTop()));
        }
        if (BorderStyle.NONE.equals(bg.getLeft().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderLeft(styleKey.getBorderStrokeLeft());
          xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.LEFT,
              new XSSFColor(styleKey.getExtendedColorLeft()));
        }
        if (BorderStyle.NONE.equals(bg.getRight().getBorderStyle()) == false)
        {
          hssfCellStyle.setBorderRight(styleKey.getBorderStrokeRight());
          xssfCellStyle.setBorderColor(XSSFCellBorder.BorderSide.RIGHT,
              new XSSFColor(styleKey.getExtendedColorRight()));
        }
        if (bg.getBackgroundColor() != null)
        {
          xssfCellStyle.setFillForegroundColor(new XSSFColor(styleKey.getExtendedColor()));
          hssfCellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
        }
      }
      else
      {
View Full Code Here


                    } else if (ctColor.getSysClr() != null) {
                       // Colour is a tint of white or black
                       rgb = ctColor.getSysClr().getLastClr();
                    }

                    return new XSSFColor(rgb);
                }
                cnt++;
            }
        }
        return null;
View Full Code Here

          // No theme set, nothing to do
          return;
       }
      
       // Get the theme colour
       XSSFColor themeColor = getThemeColor(color.getTheme());
       // Set the raw colour, not the adjusted one
       // Do a raw set, no adjusting at the XSSFColor layer either
       color.getCTColor().setRgb(themeColor.getCTColor().getRgb());
      
       // All done
    }
View Full Code Here

                    } else if (ctColor.getSysClr() != null) {
                       // Colour is a tint of white or black
                       rgb = ctColor.getSysClr().getLastClr();
                    }

                    return new XSSFColor(rgb);
                }
                cnt++;
            }
        }
        return null;
View Full Code Here

        if (font.getUnderline() != FontUnderline.NONE.getByteValue()) {
            _style.underline();
        }

        if (style.getFillPatternEnum() == FillPatternType.SOLID_FOREGROUND) {
            XSSFColor fillForegroundXSSFColor = style.getFillForegroundXSSFColor();
            String argb = fillForegroundXSSFColor.getARGBHex();
            if (argb != null) {
                _style.background(argb.substring(2));
            }
        }

        final XSSFFont stdFont = _stylesTable.getStyleAt(0).getFont();
        final short fontHeight = style.getFont().getFontHeightInPoints();
        if (stdFont.getFontHeightInPoints() != fontHeight) {
            _style.fontSize(fontHeight, SizeUnit.PT);
        }

        XSSFColor fontColor = style.getFont().getXSSFColor();
        if (fontColor != null) {
            String argbHex = fontColor.getARGBHex();
            if (argbHex != null) {
                _style.foreground(argbHex.substring(2));
            }
        }
View Full Code Here

                }
            }
        } else if (font instanceof XSSFFont) {
            XSSFFont xssfFont = (XSSFFont) font;

            XSSFColor color = xssfFont.getXSSFColor();
            if (color != null) {
                String argbHex = color.getARGBHex();
                if (argbHex != null) {
                    styleBuilder.foreground(argbHex.substring(2));
                }
            }
        } else {
            throw new IllegalStateException("Unexpected font type: " + (font == null ? "null" : font.getClass()) + ")");
        }

        // Background color
        if (cellStyle.getFillPattern() == 1) {
            Color color = cellStyle.getFillForegroundColorColor();
            if (color instanceof HSSFColor) {
                short[] triplet = ((HSSFColor) color).getTriplet();
                if (triplet != null) {
                    styleBuilder.background(triplet);
                }
            } else if (color instanceof XSSFColor) {
                String argb = ((XSSFColor) color).getARGBHex();
                if (argb != null) {
                    styleBuilder.background(argb.substring(2));
                }
            } else {
                throw new IllegalStateException("Unexpected color type: " + (color == null ? "null" : color.getClass()) + ")");
            }
        }

        // alignment
        switch (cellStyle.getAlignment()) {
View Full Code Here

    assertEquals(ctFont.getColorArray(0).getRgb()[1],xssfFont.getXSSFColor().getRgb()[1]);
    assertEquals(ctFont.getColorArray(0).getRgb()[2],xssfFont.getXSSFColor().getRgb()[2]);
    assertEquals(ctFont.getColorArray(0).getRgb()[3],xssfFont.getXSSFColor().getRgb()[3]);

    color.setRgb(Integer.toHexString(0xF1F1F1).getBytes());
    XSSFColor newColor=new XSSFColor(color);
    xssfFont.setColor(newColor);
    assertEquals(ctFont.getColorArray(0).getRgb()[2],newColor.getRgb()[2]);
  }
View Full Code Here

  }

  private XSSFColor createXSSFColor(final Color clr)
  {
    byte[] rgb = {(byte) 255, (byte) clr.getRed(), (byte) clr.getGreen(), (byte) clr.getBlue()};
    return new XSSFColor(rgb);
  }
View Full Code Here

  {
  }

  public short getNearestColor(final Color awtColor)
  {
    XSSFColor color = new XSSFColor( awtColor );
    return color.getIndexed();
  }
View Full Code Here

    if (c == null) {
      return;
    }
       
    CellStyle style = c.getCellStyle();
    XSSFColor fgColor = ((XSSFFont) getFont(c)).getXSSFColor();
   
    if ((fgColor != null) && (fgColor.getIndexed() != defaultFGColor)) {
      convertColour(fgColor, "color", out);     
    }
   
    XSSFColor bgColor = (XSSFColor) style.getFillForegroundColorColor();
    if ((bgColor != null) && (bgColor.getIndexed() != defaultBGColor)) {
      convertColour(bgColor, "background-color", out);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.xssf.usermodel.XSSFColor

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.