/// <summary> /// Get All Formats ordered by less prioritary for the given Cell, then call MergeFormats() /// Override MergeFormats() to change the default behavior, which is only taking the 4th format (the last one) /// </summary> public void ApplyFormatToCell(IWorkbook wb, RowDefinition defaultRowDef, RowDefinition rowDef, int columnIndex, ICell cell) { List <T> formats = FormatMerger.GetFormatsOrderedByLessPrioritary <T>(defaultRowDef, rowDef, columnIndex); var mergedFormat = MergeFormats(formats); if (mergedFormat != null) { ApplyFormatToCell(wb, cell, mergedFormat); } }
public void ApplyFormatToCell(IXLWorkbook wb, RowDefinition defaultRowDef, RowDefinition rowDef, int columnIndex, IXLCell cell) { var formats = FormatMerger.GetFormatsOrderedByLessPrioritary <ClosedXmlFormat>(defaultRowDef, rowDef, columnIndex); formats.Reverse(); Func <IXLStyle, IXLStyle> f = (s) => null; var composedStylize = formats.Aggregate(f, (mergedFormat, nextFormat) => { return(mergedFormat.Compose(nextFormat.Stylize)); }); ApplyFormatToCell(wb, cell, new ClosedXmlFormat(composedStylize)); }