Spire.XLS for .NET is a professional Excel .NET component that can be used to any type of .NET 2.0, 3.5, 4.0 or 4.5 framework application, both ASP.NET web sites and Windows Forms application.

Fri Jan 11, 2013 3:37 pm

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

mzahumensky
 
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
oBook.CalculateAllValue()

mzahumensky
 
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,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2275
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.XLS