Category / Section
How to set conditional formatting for numbers?
1 min read
Use the following code snippets to set conditional formatting for numbers.
C#
//Applying conditional formatting to "A3" for format type as CellValue( Equal) IConditionalFormats condition2 = sheet.Range["A3"].ConditionalFormats; //Adding formats to IConditionalFormats collection IConditionalFormat condition3 = condition2.AddCondition(); sheet.Range["A3"].Text = "Enter the Number as 1000"; //Setting format properties. condition3.FormatType = ExcelCFType.CellValue; condition3.Operator = ExcelComparisonOperator.Equal; condition3.FirstFormula = "1000"; condition3.FontColorRGB = Color.FromArgb(0xde, 0x64, 0x13);
VB
'Applying conditional formatting to "A3" for format type as CellValue( Equal) Dim condition2 As IConditionalFormats = sheet.Range("A3").ConditionalFormats 'Adding formats to IConditionalFormats collection Dim condition3 As IConditionalFormat = condition2.AddCondition() sheet.Range("A3").Text = "Enter the Number as 1000" 'Setting format properties. condition3.FormatType = ExcelCFType.CellValue condition3.Operator = ExcelComparisonOperator.Equal condition3.FirstFormula = "1000" condition3.FontColorRGB = Color.FromArgb(204, 212, 230)