GcSpreadSheet supports conditional formatting in cells. You can use styles to set the visual appearance of the formatted cell. There are several types of conditional rules. They are as follows:
The average rule checks for values above or under the average. The cell value rule compares values. The date rule compares dates. The formula rule allows you to use formulas when checking the condition.
The specific text rule searches for text strings. The top 10 rule checks for values in the top or bottom of the range.
The unique rule checks to see if the value is the only one of that value in the range (if the duplicate option is false). The duplicate rule checks for duplicate values.
The data bar rule displays a bar in the cell based on the cell value in the range. You can also specify the type and color of the bar or borders. You can specify the axis position and color as well. The following image displays a data bar rule.
The icon set rule displays icons based on the values. You can specify the type of icon and whether to show the icon or the icon and the data in the cell. The following image displays an icon rule.
The scale rule uses a sliding color scale. For example if 1 is yellow and 50 is green, then 25 would be light green. The scale rule has an option for two or three colors in the scale (TwoColorScaleRule class or ThreeColorScaleRule class). The following image is for a three scale rule.
The StyleInfo class can be used to set styles for rules that do not have color or icon properties.
This example creates a three color scale rule.
CS |
Copy Code |
---|---|
var rule = GrapeCity.Xaml.SpreadSheet.Data.ThreeColorScaleRule.Create(GrapeCity.Xaml.SpreadSheet.Data.ScaleValueType.Number, 1, Windows.UI.Colors.Yellow, GrapeCity.Xaml.SpreadSheet.Data.ScaleValueType.Number, 50, Windows.UI.Colors.Blue, GrapeCity.Xaml.SpreadSheet.Data.ScaleValueType.Number, 100, Windows.UI.Colors.Red); rule.Ranges = new GrapeCity.Xaml.SpreadSheet.Data.CellRange[] { new GrapeCity.Xaml.SpreadSheet.Data.CellRange(0, 0, 20, 1) }; gcSpreadSheet1.Sheets[0].ConditionalFormats.AddRule(rule); |
VB |
Copy Code |
---|---|
Dim rule = GrapeCity.Xaml.SpreadSheet.Data.ThreeColorScaleRule.Create(GrapeCity.Xaml.SpreadSheet.Data.ScaleValueType.Number, 1, Windows.UI.Colors.Yellow, GrapeCity.Xaml.SpreadSheet.Data.ScaleValueType.Number, 50, Windows.UI.Colors.Blue, _ GrapeCity.Xaml.SpreadSheet.Data.ScaleValueType.Number, 100, Windows.UI.Colors.Red) rule.Ranges = New GrapeCity.Xaml.SpreadSheet.Data.CellRange() {New GrapeCity.Xaml.SpreadSheet.Data.CellRange(0, 0, 20, 1)} GcSpreadSheet1.Sheets(0).ConditionalFormats.AddRule(rule) |