)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Can we set multiple conditional formatting using XlsIO?

Platform: WinForms |
Control: XlsIO |
Published Date: April 30, 2011 |
Last Revised Date: December 4, 2019

Yes, we can set multiple conditional formatting using XlsIO. Use the following code snippets to set multiple conditional formatting.

C#

//Applying conditional formatting to "A1:C5" for format type as CellValue( Between)
IConditionalFormats condition = sheet.Range["A1:C5"].ConditionalFormats;
//Adding formats to IConditionalFormats collection
IConditionalFormat condition1 = condition.AddCondition();
condition1.FirstFormula = "5";
condition1.SecondFormula = "10";
//Setting format properties.
condition1.Operator = ExcelComparisonOperator.Between;
condition1.FormatType = ExcelCFType.CellValue;
condition1.BackColorRGB = Color.FromArgb(238, 122, 3);
condition1.IsBold = true;
condition1.IsItalic = true;
//Applying conditional formatting to "A1:C5" for format type as CellValue( Equal)
IConditionalFormats condition2 = sheet.Range["A1:C5"].ConditionalFormats;
//Adding formats to IConditionalFormats collection
IConditionalFormat condition3 = condition2.AddCondition();
//Setting format properties.
condition3.FormatType = ExcelCFType.CellValue;
condition3.Operator = ExcelComparisonOperator.Equal;
condition3.FirstFormula = "20";
condition3.FontColorRGB = Color.FromArgb(0xde, 0x64, 0x13);

 

VB

'Applying conditional formatting to "A1:C5" for format type as CellValue( Between)
Dim condition As IConditionalFormats = sheet.Range("A1:C5").ConditionalFormats
'Adding formats to IConditionalFormats collection
Dim condition1 As IConditionalFormat = condition.AddCondition()
condition1.FirstFormula = "5"
condition1.SecondFormula = "10"
'Setting format properties.
condition1.Operator = ExcelComparisonOperator.Between
condition1.FormatType = ExcelCFType.CellValue
condition1.BackColorRGB = Color.FromArgb(238, 122, 3)
condition1.IsBold = True
condition1.IsItalic = True
'Applying conditional formatting to "A1:C5" for format type as CellValue( Equal)
Dim condition2 As IConditionalFormats = sheet.Range("A1:C5").ConditionalFormats
'Adding formats to IConditionalFormats collection
Dim condition3 As IConditionalFormat = condition2.AddCondition()
'Setting format properties.
condition3.FormatType = ExcelCFType.CellValue
condition3.Operator = ExcelComparisonOperator.Equal
condition3.FirstFormula = "20"
condition3.FontColorRGB = Color.FromArgb(&HDE, &H64, &H13)

 

Here is the sample for your reference:

Multiple_ConditionalFormatting.zip

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon