/** * Set the foreground fill color represented as a {@link XSSFColor} value. * <br/> * <i>Note: Ensure Foreground color is Set prior to background color.</i> * @param color the color to use * @see #setFillBackgroundColor(NPOI.xssf.usermodel.XSSFColor) ) */ public void SetFillForegroundColor(XSSFColor color) { CT_Fill ct = GetCTFill(); CT_PatternFill ptrn = ct.GetPatternFill(); if (color == null) { if (ptrn != null) { ptrn.unsetFgColor(); } } else { if (ptrn == null) { ptrn = ct.AddNewPatternFill(); } ptrn.fgColor = (color.GetCTColor()); } int idx = _stylesSource.PutFill(new XSSFCellFill(ct)); _cellXf.fillId = (uint)idx; _cellXf.applyFill = (true); }
public void SetFillForegroundColor(XSSFColor color) { CT_Fill ctFill = this.GetCTFill(); CT_PatternFill ctPatternFill = ctFill.GetPatternFill(); if (color == null) { ctPatternFill?.unsetFgColor(); } else { if (ctPatternFill == null) { ctPatternFill = ctFill.AddNewPatternFill(); } ctPatternFill.fgColor = color.GetCTColor(); } this._cellXf.fillId = (uint)this._stylesSource.PutFill(new XSSFCellFill(ctFill)); this._cellXf.applyFill = true; }