Spire.XLS for .NET is a professional Excel .NET library that can be used to any type of .NET( C#, VB.NET, ASP.NET, .NET Core) application and Java (J2SE and J2EE) application.

Fri Jan 11, 2013 3:37 pm

Is it possible to get some sample with conditional formating in Excel?

Posts: 18
Joined: Fri May 20, 2011 11:29 am

Fri Jan 11, 2013 5:24 pm

I made some simple condition in VB, maybe it helps to someone else. I hope it is correct.

Code: Select all
oBook = New Workbook()
oSheet = oBook.Worksheets(0)

Dim objCond As Spire.Xls.ConditionalFormatWrapper
objCond = oSheet.Range(3, 3).ConditionalFormats.AddCondition()
objCond.FormatType = ConditionalFormatType.Formula
objCond.FirstFormula = "=$C$3 > $A$3 + $B$3"
objCond.Operator = ComparisonOperatorType.Greater
objCond.BackColor = Color.Red

oSheet.Range(3, 1).NumberValue = 2
oSheet.Range(3, 2).NumberValue = 4
oSheet.Range(3, 3).NumberValue = 7

Posts: 18
Joined: Fri May 20, 2011 11:29 am

Mon Jan 14, 2013 7:17 am

Hello Martin,

Thank you for sharing.
Your code will work well. It will very useful.

Best regards,
E-iceblue support team
User avatar

Posts: 2438
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.XLS