Compartilhar via


Propriedade NamedRange.FormatConditions

Obtém uma coleção de FormatConditions que representa todos os formatos condicionais para o controle de NamedRange .

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (em Microsoft.Office.Tools.Excel.dll)

Sintaxe

'Declaração
ReadOnly Property FormatConditions As FormatConditions
FormatConditions FormatConditions { get; }

Valor de propriedade

Tipo: Microsoft.Office.Interop.Excel.FormatConditions
Uma coleção de FormatConditions que representa todos os formatos condicionais para o controle de NamedRange .

Exemplos

O exemplo de código a seguir cria NamedRange e usar a propriedade de FormatConditions para alterar a fonte em NamedRange se o valor em NamedRange é menor que o valor da célula A1.

Este exemplo é para uma personalização de um documento nível.

Private formatConditionsRange As Microsoft.Office.Tools.Excel.NamedRange

Private Sub ModifyFormatConditions()
    formatConditionsRange = Me.Controls.AddNamedRange( _
        Me.Range("B1"), "formatConditionsRange")
    Me.Range("A1").Value2 = 99000
    Me.formatConditionsRange.Value2 = 98052

    ' Set conditional formatting to alter the font if 
    ' the formatConditionsRange value is less than the value in A1.
    Dim condition1 As Excel.FormatCondition = _
        Me.formatConditionsRange.FormatConditions.Add( _
        Excel.XlFormatConditionType.xlCellValue, _
        Excel.XlFormatConditionOperator.xlLess, "=$a$1", )

    condition1.Font.Bold = True
    condition1.Font.Color = &HFF00
End Sub
Microsoft.Office.Tools.Excel.NamedRange formatConditionsRange;
private void ModifyFormatConditions()
{
    formatConditionsRange = this.Controls.AddNamedRange(
        this.Range["B1"], "formatConditionsRange");
    this.Range["A1"].Value2 = 99000;
    this.formatConditionsRange.Value2 = 98052;

    // Set conditional formatting to alter the font if 
    // the formatConditionsRange value is less than the value in A1.
    Excel.FormatCondition condition1 =
        (Excel.FormatCondition)this.formatConditionsRange.FormatConditions.Add(
        Excel.XlFormatConditionType.xlCellValue,
        Excel.XlFormatConditionOperator.xlLess, "=$a$1");

    condition1.Font.Bold = true;
    condition1.Font.Color = 0xFF00;
}

Segurança do .NET Framework

Consulte também

Referência

NamedRange Interface

Namespace Microsoft.Office.Tools.Excel