Conditional Formatting Above and Below Average
Output: ConditionalFormattingAboveAverage.xlsx
public void Run()
{
var workbook = new Workbook();
var worksheet = workbook.Worksheets[0];
worksheet.Columns[0].WidthCharacters = 55;
worksheet.Columns.SetWidthCharacters("B", "F", 5);
worksheet["A1"].Value = "Above Average Accent3";
worksheet.GetRange("B1:F1").SetValue(new int[] { 1, 2, 3, 4, 5 });
var ruleB1 = worksheet.ConditionalFormattings.AddAboveAverage("B1:F1", true);
ruleB1.Fill = CellFill.CreateSolidFill(SpreadsheetColor.Accent3);
worksheet["A2"].Value = "Below Average Accent2";
worksheet.GetRange("B2:F2").SetValue(new int[] { 1, 2, 3, 4, 5 });
var ruleB2 = worksheet.ConditionalFormattings.AddAboveAverage("B2:F2", false);
ruleB2.Fill = CellFill.CreateSolidFill(SpreadsheetColor.Accent2);
workbook.SaveAs("ConditionalFormattingAboveAverage.xlsx");
}