Spread.Services Documentation
Add Average Rule
Spread.Services Documentation > Developer's Guide > Apply Conditional Formatting > Add Average Rule

The average rule in conditional formatting can be added and deleted using the properties and methods of the IAboveAverage interface.

Refer to the following example code to add average rule to a range of cells in a worksheet.

C#
Copy Code
// Adding average rule
worksheet.Range["A1"].Value = 1;
worksheet.Range["A2"].Value = 2;
worksheet.Range["A3"].Value = 3;
worksheet.Range["A4"].Value = 4;
worksheet.Range["A5"].Value = 60000000;

IAboveAverage averageCondition = worksheet.Range["A1:A5"].FormatConditions.AddAboveAverage();
averageCondition.AboveBelow = AboveBelow.AboveAverage;
averageCondition.NumStdDev = 2;
averageCondition.NumberFormat = "0.00";