/** * Create an instance of XSSFColor from the supplied XML bean, with default color indexes * @param color The {@link CTColor} to use as color-value. * @deprecated 3.17 beta 1 - pass the workbook styles indexed color map, if any */ @Deprecated @Removal(version="4.2") public XSSFColor(CTColor color) { this(color, new DefaultIndexedColorMap()); }
/** * Create an instance of XSSFColor from the awt Color * @param clr awt Color * @deprecated 3.17 beta 1 - pass the workbook styles indexed color map, if any */ @Deprecated @Removal(version="4.2") public XSSFColor(java.awt.Color clr) { this(clr, new DefaultIndexedColorMap()); }
/** * Create an new instance of XSSFColor, without knowledge of any custom indexed colors. * This is OK for just transiently setting indexes, etc. but is discouraged in read/get uses * @deprecated as of 4.0.0, we want to have the indexed map, and all calling contexts have access to it. * @see #XSSFColor(IndexedColorMap) * @see #from(CTColor, IndexedColorMap) */ @Deprecated @Removal(version="4.2") public XSSFColor() { this(CTColor.Factory.newInstance(), new DefaultIndexedColorMap()); }
/** * Create an instance of XSSFColor from the supplied XML bean, with default color indexes * @param color The {@link CTColor} to use as color-value. * @deprecated 3.17 beta 1 - pass the workbook styles indexed color map, if any */ @Deprecated @Removal(version="4.2") public XSSFColor(CTColor color) { this(color, new DefaultIndexedColorMap()); }
/** * Create an instance of XSSFColor from the awt Color * @param clr awt Color * @deprecated 3.17 beta 1 - pass the workbook styles indexed color map, if any */ @Deprecated @Removal(version="4.2") public XSSFColor(java.awt.Color clr) { this(clr, new DefaultIndexedColorMap()); }
/** * Create an new instance of XSSFColor, without knowledge of any custom indexed colors. * This is OK for just transiently setting indexes, etc. but is discouraged in read/get uses * @deprecated as of 4.0.0, we want to have the indexed map, and all calling contexts have access to it. * @see #XSSFColor(IndexedColorMap) * @see #from(CTColor, IndexedColorMap) */ @Deprecated @Removal(version="4.2") public XSSFColor() { this(CTColor.Factory.newInstance(), new DefaultIndexedColorMap()); }
public ExcelSheet tabColour(IndexedColors colour) { if (sheet() instanceof XSSFSheet) { ((XSSFSheet) sheet()).setTabColor(new XSSFColor(colour, new DefaultIndexedColorMap())); } else if (sheet() instanceof SXSSFSheet) { ((SXSSFSheet) sheet()).setTabColor(new XSSFColor(colour, new DefaultIndexedColorMap())); } return this; }
private static void setCustomColor(Workbook workbook, CellStyle style, int r, int g, int b, AtomicInteger colorIndex) { if (workbook instanceof HSSFWorkbook) { HSSFWorkbook hssfWorkbook = (HSSFWorkbook) workbook; HSSFPalette palette = hssfWorkbook.getCustomPalette(); short index = (short) colorIndex.getAndIncrement(); palette.setColorAtIndex(index, (byte) r, (byte) g, (byte) b); style.setFillForegroundColor(index); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); } else { XSSFCellStyle xssfCellStyle = (XSSFCellStyle) style; xssfCellStyle.setFillForegroundColor(new XSSFColor(new Color(r, g, b), new DefaultIndexedColorMap())); style.setFillPattern(FillPatternType.SOLID_FOREGROUND); } }