Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Description

Excerpt

Creates a Condition of the specified ComparisonType.

Signature
C#
C#
 public Condition CreateCondition(Comparison comparisonType, System.String formula1, System.String formula2)
Signature
vb.net
vb.net
Public Function CreateCondition(ByVal comparisonType As Comparison, ByVal formula1 As String, ByVal formula2 As String) As Condition
Parameters
Param
comparisonType
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 or Condition.Comparison.CellValueNotBetween..

Param
formula1
formula1

The formula to use for the minumum value.

Param
formula2
formula2

The formula to use for the maximum value.

Returns

A Condition object representing the condition created.

Example
Code Block
csharp
csharp
titleC#

          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
vb.net
vb.net
titlevb.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)