Skip to main content Skip to footer

GrapeCity Spread Silverlight CTP, Part 8 - Conditional Formatting

Spread CTP - Script 8: Conditional Formatting

If you are interested in downloading the Spread CTP, please email labs@grapecity.com .

This is the 8th in a series of Spread CTP Blogs and is a continuation of:

Part 1 : Create an app from scratch
Part 2 : AutoFit
Part 3 : Borders and Grid Lines
Part 4 : Cell Format
Part 5 : Cell Overflow
Part 6 : Cell Span
Part 7 : Clipboard Operation

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:

· AverageRule Class The average rule checks for values above or under the average.

· CellValueRule Class The cell value rule compares values.

· DateOccurringRule Class The date rule compares dates.

· FormulaRule Class The formula rule allows you to use formulas when checking the condition.

· ScaleRule Class The scale rule uses a sliding color scale. For example if 1 is yellow and 50 is green, then 25 would be light green.

· SpecificTextRule Class The specific text rule searches for text strings.

· Top10Rule Class The top 10 rule checks for values in the top or bottom of the range.

· UniqueRule Class 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 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.

Using Code

CS

var rule = GrapeCity.Windows.SpreadSheet.Data.ThreeColorScaleRule.Create(GrapeCity.Windows.SpreadSheet.Data.ScaleValueType.Number, 1, Colors.Yellow, GrapeCity.Windows.SpreadSheet.Data.ScaleValueType.Number, 50, Colors.Blue, GrapeCity.Windows.SpreadSheet.Data.ScaleValueType.Number, 100, Colors.Red);
rule.Ranges = new GrapeCity.Windows.SpreadSheet.Data.CellRange[] { new GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 0, 20, 1) };
gcSpreadSheet1.Sheets[0].ConditionalFormats.AddRule(rule);

VB.NET

Dim rule = GrapeCity.Windows.SpreadSheet.Data.ThreeColorScaleRule.Create(GrapeCity.Windows.SpreadSheet.Data.ScaleValueType.Number, 1, Colors.Yellow, GrapeCity.Windows.SpreadSheet.Data.ScaleValueType.Number, 50, Colors.Blue, _
GrapeCity.Windows.SpreadSheet.Data.ScaleValueType.Number, 100, Colors.Red)
rule.Ranges = New GrapeCity.Windows.SpreadSheet.Data.CellRange() {New GrapeCity.Windows.SpreadSheet.Data.CellRange(0, 0, 20, 1)}
GcSpreadSheet1.Sheets(0).ConditionalFormats.AddRule(rule)

Enter values to test it out… -1, 50, 100, etc…

clip_image001

Part 9 CSV Import and Export

Spread, Excel, Silverlight, CTP, labs@grapecity.com , visual studio, AutoFit, borders and Grid lines, cell format, cell overflow, cell span, clipboard, clipboard operation, conditional formatting, CSV, CSV Import and Export

tweetmeme_url = 'http://www.clubfarpoint.com/Forums/blogs/russells\_blog/archive/2012/03/28/grapecity-spread-silverlight-ctp-part-8-conditional-formatting.aspx'; tweetmeme_source = '@russcamtv'; tweetmeme_hashtags = '#appdev';

MESCIUS inc.

comments powered by Disqus