Signature |
---|
C# | C# | Wiki Markup |
---|
{description}
{excerpt}Creates a [Condition] of the specified [ComparisonType|Condition.ComparisonType].{excerpt}
{signature:C#}
public Condition CreateCondition(Comparison comparisonType, System.String formula1, System.String formula2)
|
Signature |
---|
{signature}{signature:vb.net | vb.net | }
Public Function CreateCondition(ByVal comparisonType As Comparison, ByVal formula1 As String, ByVal formula2 As String) As Condition
|
...
A Condition constant representing the type of comparison Excel will use when comparing a cell value to the parameters formula1
and formula2
. The comparison type must require two formulas and may be set to one of the following values: Condition.Comparison.CellValueBetween or Condition.Comparison.CellValueNotBetween..
...
The formula to use for the minumum value.
...
The formula to use for the maximum value.
Returns |
---|
A Condition object representing the condition created. |
Example |
---|
Code Block |
---|
| csharp | csharp |
title | C# |
---|
{signature}
{parameters}
{param:comparisonType}A [Condition] constant representing the type of comparison Excel will use when comparing a cell value to the parameters {{formula1}} and {{formula2}}. The comparison type must require two formulas and may be set to one of the following values: [Condition.Comparison.CellValueBetween|Condition.Comparison#CellValueBetween] or [Condition.Comparison.CellValueNotBetween|Condition.Comparison#CellValueNotBetween]..
{param}
{param:formula1}The formula to use for the minumum value.{param}
{param:formula2}The formula to use for the maximum value.{param}
{returns}A [Condition|Condition] object representing the condition created.{returns}
{example}{code:csharp|title=C#}
ExcelApplication xla = new ExcelApplication();
Workbook wb = xla.Create();
Range rng = wb.Worksheest[0].CreateRange("$B$2:$F$10");
ConditionalFormat condFmt = wb.CreateConditionalFormat();
Condition cond =
condFmt.CreateCondition(
Condition.Comparison.CellValueBetween,
"=100",
"=150");
Font fnt = cond.Style.Font;
fnt.Bold = true;
fnt.Color = wb.Palette.GetClosestColor(100, 100, 255);
rng.SetConditionalFormat(condFmt);
Code Block |
---|
{code}
{code:vb.net
vb.net | title | |title=vb.net
}
Dim xla As New ExcelApplication()
Dim wb As Workbook = xla.Create()
Dim rng As Range = wb.Worksheets(0).CreateRange("$B$2:$F$10")
Dim condFmt As ConditionalFormat = wb.CreateConditionalFormat()
Dim cond As Condition = _
condFmt.CreateCondition( _
Condition.Comparison.CellValueBetween, _
"=100", _
"=150")
Dim fnt As Font = cond.Style.Font
fnt.Bold = True
fnt.Color = wb.Palette.GetClosestColor(100, 100, 255)
rng.SetConditionalFormat(condFmt)
{code}
{example}