Refine search
XSSFColor backgroundColor = new XSSFColor(Color.decode(facetBackground)); ((XSSFCellStyle) facetStyle).setFillForegroundColor(backgroundColor); facetStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); XSSFColor facetColor = new XSSFColor(Color.decode(facetFontColor)); ((XSSFFont) facetFont).setColor(facetColor);
/** * Get the foreground fill color. * <p> * Many cells are filled with this, instead of a * background color ({@link #getFillBackgroundColor()}) * </p> * @see IndexedColors * @return fill color, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#AUTOMATIC} */ @Override public short getFillForegroundColor() { XSSFColor clr = getFillForegroundXSSFColor(); return clr == null ? IndexedColors.AUTOMATIC.getIndex() : clr.getIndexed(); }
@Override public void setFontColor(Color color) { XSSFColor xcolor = XSSFColor.toXSSFColor(color); if (xcolor == null) { _font.getColorList().clear(); } else if(_font.sizeOfColorArray() == 0) { _font.addNewColor().setRgb(xcolor.getRGB()); } else { _font.setColorArray(0, xcolor.getCTColor()); } }
private boolean sameIndexed(XSSFColor other) { if (isIndexed() == other.isIndexed()) { return !isIndexed() || getIndexed() == other.getIndexed(); } return false; } private boolean sameARGB(XSSFColor other) {
XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = wb.createSheet(); XSSFRow row = sheet.createRow(0); XSSFCell cell = row.createCell( 0); cell.setCellValue("custom XSSF colors"); XSSFCellStyle style1 = wb.createCellStyle(); style1.setFillForegroundColor(new XSSFColor(new java.awt.Color(128, 0, 128))); style1.setFillPattern(CellStyle.SOLID_FOREGROUND);
CellStyle createHeaderStyle(Workbook wb){ XSSFCellStyle xstyle = (XSSFCellStyle)wb.createCellStyle(); XSSFColor header = new XSSFColor(new Color(79, 129, 189)); xstyle.setFillForegroundColor(header); xstyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); XSSFFont font = (XSSFFont)wb.createFont(); font.setColor(IndexedColors.WHITE.index); xstyle.setFont(font); return xstyle; }
/** * @param color * @param map * @return null if color is null, new instance otherwise */ public static XSSFColor from(CTColor color, IndexedColorMap map) { return color == null ? null : new XSSFColor(color, map); }
/** * Set the foreground fill color as a indexed color value * <br/> * <i>Note: Ensure Foreground color is set prior to background color.</i> * @param fg the color to use * @see org.apache.poi.ss.usermodel.IndexedColors */ public void setFillForegroundColor(short fg) { XSSFColor clr = new XSSFColor(); clr.setIndexed(fg); setFillForegroundColor(clr); }
private void configureStyle(XSSFCellStyle style) { XSSFFont font = style.getFont(); if (font.getBold()) { _style.bold(); if (style.getFillPatternEnum() == FillPatternType.SOLID_FOREGROUND) { XSSFColor fillForegroundXSSFColor = style .getFillForegroundXSSFColor(); String argb = fillForegroundXSSFColor.getARGBHex(); if (argb != null) { _style.background(argb.substring(2)); XSSFColor fontColor = style.getFont().getXSSFColor(); if (fontColor != null) { String argbHex = fontColor.getARGBHex(); if (argbHex != null) { _style.foreground(argbHex.substring(2));
/** * Set the color to use for the bottom border * @param color the index of the color definition * @see org.apache.poi.ss.usermodel.IndexedColors */ public void setBottomBorderColor(short color) { XSSFColor clr = new XSSFColor(); clr.setIndexed(color); setBottomBorderColor(clr); }
/** * Set the color to use for the left border as a indexed color value * * @param color the index of the color definition * @see org.apache.poi.ss.usermodel.IndexedColors */ public void setLeftBorderColor(short color) { XSSFColor clr = new XSSFColor(); clr.setIndexed(color); setLeftBorderColor(clr); }
/** * Set the color to use for the right border * * @param color the index of the color definition * @see org.apache.poi.ss.usermodel.IndexedColors */ public void setRightBorderColor(short color) { XSSFColor clr = new XSSFColor(); clr.setIndexed(color); setRightBorderColor(clr); }
/** * Set the color to use for the top border * * @param color the index of the color definition * @see org.apache.poi.ss.usermodel.IndexedColors */ public void setTopBorderColor(short color) { XSSFColor clr = new XSSFColor(); clr.setIndexed(color); setTopBorderColor(clr); }
XSSFCellStyle cellStyle = workbook.createCellStyle(); XSSFColor color = new XSSFColor(new java.awt.Color(128, 0, 128)); cellStyle.setBorderColor(XSSFCellBorder.BorderSide.BOTTOM, color); cellStyle.setBottomBorderColor(color);
private CellStyle buildCellStyle(XSSFCell cell,XSSFWorkbook book){ CellStyle style=new CellStyle(); XSSFCellStyle cellStyle=cell.getCellStyle(); HorizontalAlignment align=cellStyle.getAlignmentEnum(); if(align.equals(HorizontalAlignment.CENTER)){ style.setAlign(Alignment.center); style.setAlign(Alignment.left); VerticalAlignment valign=cellStyle.getVerticalAlignmentEnum(); if(valign.equals(VerticalAlignment.BOTTOM)){ style.setValign(Alignment.bottom); style.setValign(Alignment.middle); XSSFFont font=cellStyle.getFont(); if(font.getBold()){ style.setBold(true); String rgb=color.getARGBHex(); style.setForecolor(hex2Rgb(rgb)); }else{ XSSFColor bgcolor=cellStyle.getFillForegroundColorColor(); if(bgcolor!=null){ String hex=bgcolor.getARGBHex(); style.setBgcolor(hex2Rgb(hex));
public short getNearestColor( final Color awtColor ) { XSSFColor color = new XSSFColor( awtColor ); return color.getIndexed(); } }
if (cellColor instanceof XSSFColor) { XSSFColor xssfCellColor = (XSSFColor) cellColor; if(xssfCellColor.getARGBHex().equals(new XSSFColor(java.awt.Color.GREEN).getARGBHex())) { System.out.print(0+","); } else if(xssfCellColor.getARGBHex().equals(new XSSFColor(java.awt.Color.YELLOW).getARGBHex())) { System.out.print(1+",");
public static XSSFColor getColor(short[] color, XSSFWorkbook workbook) { byte rgb[] = new byte[3]; for (int i = 0; i < 3; i++) { rgb[i] = (byte) (color[i] & 0xFF); } IndexedColorMap indexedColors = workbook.getStylesSource().getIndexedColors(); XSSFColor xssfColor = new XSSFColor(indexedColors); xssfColor.setRGB(rgb); return xssfColor; }
public Color getAwtColor(XSSFColor color) { if(color == null){ return Color.BLACK; } if (color.getRgb() != null) { return new Color(ByteBuffer.wrap(color.getRgb()).getInt(), true); } else { if(color.getIndexed() == 64){ return Color.BLACK; } return getAwtColor(color.getTheme(), color.getTint()); } }
XSSFFont font = cs.getFont(); System.out.println("Font color : " + color.getARGBHex());