org.apache.poi.xssf.usermodel.XSSFColor类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(700)

本文整理了Java中org.apache.poi.xssf.usermodel.XSSFColor类的一些代码示例,展示了XSSFColor类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XSSFColor类的具体详情如下:
包路径:org.apache.poi.xssf.usermodel.XSSFColor
类名称:XSSFColor

XSSFColor介绍

[英]Represents a color in SpreadsheetML
[中]表示电子表格ML中的颜色

代码示例

代码示例来源:origin: primefaces/primefaces

  1. XSSFColor backgroundColor = new XSSFColor(Color.decode(facetBackground));
  2. ((XSSFCellStyle) facetStyle).setFillForegroundColor(backgroundColor);
  3. facetStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
  4. XSSFColor facetColor = new XSSFColor(Color.decode(facetFontColor));
  5. ((XSSFFont) facetFont).setColor(facetColor);

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. /**
  2. * Get the foreground fill color.
  3. * <p>
  4. * Many cells are filled with this, instead of a
  5. * background color ({@link #getFillBackgroundColor()})
  6. * </p>
  7. * @see IndexedColors
  8. * @return fill color, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#AUTOMATIC}
  9. */
  10. @Override
  11. public short getFillForegroundColor() {
  12. XSSFColor clr = getFillForegroundXSSFColor();
  13. return clr == null ? IndexedColors.AUTOMATIC.getIndex() : clr.getIndexed();
  14. }

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. @Override
  2. public void setFontColor(Color color) {
  3. XSSFColor xcolor = XSSFColor.toXSSFColor(color);
  4. if (xcolor == null) {
  5. _font.getColorList().clear();
  6. } else if(_font.sizeOfColorArray() == 0) {
  7. _font.addNewColor().setRgb(xcolor.getRGB());
  8. } else {
  9. _font.setColorArray(0, xcolor.getCTColor());
  10. }
  11. }

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. private boolean sameIndexed(XSSFColor other) {
  2. if (isIndexed() == other.isIndexed()) {
  3. return !isIndexed() || getIndexed() == other.getIndexed();
  4. }
  5. return false;
  6. }
  7. private boolean sameARGB(XSSFColor other) {

代码示例来源:origin: stackoverflow.com

  1. XSSFWorkbook wb = new XSSFWorkbook();
  2. XSSFSheet sheet = wb.createSheet();
  3. XSSFRow row = sheet.createRow(0);
  4. XSSFCell cell = row.createCell( 0);
  5. cell.setCellValue("custom XSSF colors");
  6. XSSFCellStyle style1 = wb.createCellStyle();
  7. style1.setFillForegroundColor(new XSSFColor(new java.awt.Color(128, 0, 128)));
  8. style1.setFillPattern(CellStyle.SOLID_FOREGROUND);

代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons

  1. CellStyle createHeaderStyle(Workbook wb){
  2. XSSFCellStyle xstyle = (XSSFCellStyle)wb.createCellStyle();
  3. XSSFColor header = new XSSFColor(new Color(79, 129, 189));
  4. xstyle.setFillForegroundColor(header);
  5. xstyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
  6. XSSFFont font = (XSSFFont)wb.createFont();
  7. font.setColor(IndexedColors.WHITE.index);
  8. xstyle.setFont(font);
  9. return xstyle;
  10. }

代码示例来源:origin: org.apache.poi/poi-ooxml

  1. /**
  2. * @param color
  3. * @param map
  4. * @return null if color is null, new instance otherwise
  5. */
  6. public static XSSFColor from(CTColor color, IndexedColorMap map) {
  7. return color == null ? null : new XSSFColor(color, map);
  8. }

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. /**
  2. * Set the foreground fill color as a indexed color value
  3. * <br/>
  4. * <i>Note: Ensure Foreground color is set prior to background color.</i>
  5. * @param fg the color to use
  6. * @see org.apache.poi.ss.usermodel.IndexedColors
  7. */
  8. public void setFillForegroundColor(short fg) {
  9. XSSFColor clr = new XSSFColor();
  10. clr.setIndexed(fg);
  11. setFillForegroundColor(clr);
  12. }

代码示例来源:origin: org.eobjects.metamodel/MetaModel-excel

  1. private void configureStyle(XSSFCellStyle style) {
  2. XSSFFont font = style.getFont();
  3. if (font.getBold()) {
  4. _style.bold();
  5. if (style.getFillPatternEnum() == FillPatternType.SOLID_FOREGROUND) {
  6. XSSFColor fillForegroundXSSFColor = style
  7. .getFillForegroundXSSFColor();
  8. String argb = fillForegroundXSSFColor.getARGBHex();
  9. if (argb != null) {
  10. _style.background(argb.substring(2));
  11. XSSFColor fontColor = style.getFont().getXSSFColor();
  12. if (fontColor != null) {
  13. String argbHex = fontColor.getARGBHex();
  14. if (argbHex != null) {
  15. _style.foreground(argbHex.substring(2));

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. /**
  2. * Set the color to use for the bottom border
  3. * @param color the index of the color definition
  4. * @see org.apache.poi.ss.usermodel.IndexedColors
  5. */
  6. public void setBottomBorderColor(short color) {
  7. XSSFColor clr = new XSSFColor();
  8. clr.setIndexed(color);
  9. setBottomBorderColor(clr);
  10. }

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. /**
  2. * Set the color to use for the left border as a indexed color value
  3. *
  4. * @param color the index of the color definition
  5. * @see org.apache.poi.ss.usermodel.IndexedColors
  6. */
  7. public void setLeftBorderColor(short color) {
  8. XSSFColor clr = new XSSFColor();
  9. clr.setIndexed(color);
  10. setLeftBorderColor(clr);
  11. }

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. /**
  2. * Set the color to use for the right border
  3. *
  4. * @param color the index of the color definition
  5. * @see org.apache.poi.ss.usermodel.IndexedColors
  6. */
  7. public void setRightBorderColor(short color) {
  8. XSSFColor clr = new XSSFColor();
  9. clr.setIndexed(color);
  10. setRightBorderColor(clr);
  11. }

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

  1. /**
  2. * Set the color to use for the top border
  3. *
  4. * @param color the index of the color definition
  5. * @see org.apache.poi.ss.usermodel.IndexedColors
  6. */
  7. public void setTopBorderColor(short color) {
  8. XSSFColor clr = new XSSFColor();
  9. clr.setIndexed(color);
  10. setTopBorderColor(clr);
  11. }

代码示例来源:origin: stackoverflow.com

  1. XSSFCellStyle cellStyle = workbook.createCellStyle();
  2. XSSFColor color = new XSSFColor(new java.awt.Color(128, 0, 128));
  3. cellStyle.setBorderColor(XSSFCellBorder.BorderSide.BOTTOM, color);
  4. cellStyle.setBottomBorderColor(color);

代码示例来源:origin: com.bstek.ureport/ureport2-console

  1. private CellStyle buildCellStyle(XSSFCell cell,XSSFWorkbook book){
  2. CellStyle style=new CellStyle();
  3. XSSFCellStyle cellStyle=cell.getCellStyle();
  4. HorizontalAlignment align=cellStyle.getAlignmentEnum();
  5. if(align.equals(HorizontalAlignment.CENTER)){
  6. style.setAlign(Alignment.center);
  7. style.setAlign(Alignment.left);
  8. VerticalAlignment valign=cellStyle.getVerticalAlignmentEnum();
  9. if(valign.equals(VerticalAlignment.BOTTOM)){
  10. style.setValign(Alignment.bottom);
  11. style.setValign(Alignment.middle);
  12. XSSFFont font=cellStyle.getFont();
  13. if(font.getBold()){
  14. style.setBold(true);
  15. String rgb=color.getARGBHex();
  16. style.setForecolor(hex2Rgb(rgb));
  17. }else{
  18. XSSFColor bgcolor=cellStyle.getFillForegroundColorColor();
  19. if(bgcolor!=null){
  20. String hex=bgcolor.getARGBHex();
  21. style.setBgcolor(hex2Rgb(hex));

代码示例来源:origin: pentaho/pentaho-reporting

  1. public short getNearestColor( final Color awtColor ) {
  2. XSSFColor color = new XSSFColor( awtColor );
  3. return color.getIndexed();
  4. }
  5. }

代码示例来源:origin: stackoverflow.com

  1. if (cellColor instanceof XSSFColor) {
  2. XSSFColor xssfCellColor = (XSSFColor) cellColor;
  3. if(xssfCellColor.getARGBHex().equals(new XSSFColor(java.awt.Color.GREEN).getARGBHex())) {
  4. System.out.print(0+",");
  5. } else if(xssfCellColor.getARGBHex().equals(new XSSFColor(java.awt.Color.YELLOW).getARGBHex())) {
  6. System.out.print(1+",");

代码示例来源:origin: openl-tablets/openl-tablets

  1. public static XSSFColor getColor(short[] color, XSSFWorkbook workbook) {
  2. byte rgb[] = new byte[3];
  3. for (int i = 0; i < 3; i++) {
  4. rgb[i] = (byte) (color[i] & 0xFF);
  5. }
  6. IndexedColorMap indexedColors = workbook.getStylesSource().getIndexedColors();
  7. XSSFColor xssfColor = new XSSFColor(indexedColors);
  8. xssfColor.setRGB(rgb);
  9. return xssfColor;
  10. }

代码示例来源:origin: jbaliuka/x4j-analytic

  1. public Color getAwtColor(XSSFColor color) {
  2. if(color == null){
  3. return Color.BLACK;
  4. }
  5. if (color.getRgb() != null) {
  6. return new Color(ByteBuffer.wrap(color.getRgb()).getInt(), true);
  7. }
  8. else {
  9. if(color.getIndexed() == 64){
  10. return Color.BLACK;
  11. }
  12. return getAwtColor(color.getTheme(), color.getTint());
  13. }
  14. }

代码示例来源:origin: stackoverflow.com

  1. XSSFFont font = cs.getFont();
  2. System.out.println("Font color : " + color.getARGBHex());

相关文章