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

Applies the specified Style to the Condition's current Style.

Signature
C#
C#
 public void ApplyStyle(Style style)
{signature}{signature:
}
Signature
vb.net
vb.net
Public Sub ApplyStyle(ByVal style As Style)
{signature}
{parameters}
{param:style}The {{Style}} object to
        apply to the {{Condition}}'s current {{Style}}.{param}
{remarks}
A {{Condition}}'s {{Style}} is the formatting that will be set on a conditionally formatted cell if the condition is met. When a {{Style}} is *applied* \(rather than *set* using the {{Style}} property\), only the differences between the new {{Style}} and existing {{Style}} properties will take effect. To completely replace a {{Condition}}'s {{Style}} with a new one, set [Condition.Style|Condition.Style].
{remarks}
{example}{code:csharp|title=C#}
Parameters
Param
style
style

The Style object to
apply to the Condition's current Style.

Remarks

A Condition's Style is the formatting that will be set on a conditionally formatted cell if the condition is met. When a Style is applied (rather than set using the Style property), only the differences between the new Style and existing Style properties will take effect. To completely replace a Condition's Style with a new one, set Condition.Style.

Example
Code Block
csharp
csharp
titleC#


          ExcelApplication xla = new ExcelApplication();
          Workbook wb = xla.Create();
          ConditionalFormat condFmt = wb.CreateConditionalFormat();
          Condition cond =
               condFmt.CreateCondition(
               Condition.Comparison.CellValueGreaterThan,
               "=100");
          cond.Style.BackgroundColor = Palette.SystemColor.Green;
          Style styleBold = wb.CreateStyle();
          styleBold.Font.Bold = true;
          cond.ApplyStyle(styleBold);
          Range rng = wb.Worksheets[0].CreateRange("$B$2:$F$10");
          rng.SetConditionalFormat(condFmt);
        
{code} {code:
Code Block
vb.net
|title=
vb.net
titlevb.net
}


          Dim xla As New ExcelApplication()
          Dim wb As Workbook = xla.Create()
          Dim condFmt As ConditionalFormat = wb.CreateConditionalFormat()
          Dim cond As Condition = _
               condFmt.CreateCondition( _
               Condition.Comparison.CellValueGreaterThan, _
               "=100")
          cond.Style.BackgroundColor = Palette.SystemColor.Green
          Dim styleBold As Style = wb.CreateStyle()
          styleBold.Font.Bold = True
          cond.ApplyStyle(styleBold)
          Dim rng As Range = wb.Worksheets[0].CreateRange("$B$2:$F$10")
          rng.SetConditionalFormat(condFmt)
        
{code} {example}