/// <summary> /// Updates the supplied <see cref="CellFormat"/> with a colour index which relates to the Fill Colour. /// The colour is created in the excel <see cref="Stylesheet"/> if it is not already there. /// </summary> /// <param name="stylesheet"></param> /// <param name="cellInfo"></param> /// <returns></returns> private static void UpdateFillColour(ExcelStylesManager stylesManager, ExcelCellStyleInfo cellInfo, ref Stylesheet stylesheet, ref CellFormat cellFormat) { if (cellFormat == null) { throw new ArgumentNullException("cellFormat"); } if (cellInfo.FillColour != null && cellInfo.FillColour.HasValue && cellInfo.FillColour.Value != System.Windows.Media.Colors.Transparent) { var fillItem = stylesManager.fills.Find(cellInfo.FillColour.Value); UInt32Value fillId = fillItem.Value; if (fillId == null) { // Add and return the index of a fill colour (Badly named as simply returns index of existing colour if it already exists) fillId = stylesheet.AddIndexedColor(cellInfo.FillColour.Value); stylesManager.fills.Add(cellInfo.FillColour.Value, fillId); } cellFormat.FillId = fillId; } }