Share via


WorkbookBase.IconSets Property

Definition

Gets the collection of built-in icon sets that can be used to apply a conditional formatting rule to a range in the workbook.

public:
 property Microsoft::Office::Interop::Excel::IconSets ^ IconSets { Microsoft::Office::Interop::Excel::IconSets ^ get(); };
public Microsoft.Office.Interop.Excel.IconSets IconSets { get; }
member this.IconSets : Microsoft.Office.Interop.Excel.IconSets
Public ReadOnly Property IconSets As IconSets

Property Value

A Microsoft.Office.Interop.Excel.IconSets collection that contains the built-in icon set objects that can be used to apply a conditional formatting rule to a range.

Examples

The following code example populates a range on Sheet1 with values from 1 to 6. The example then adds an icon set condition to the range A1:A6 with the Microsoft.Office.Interop.Excel.XlIconSet.xl3Arrows icon set.

This example is for a document-level customization.

private void SetIconSetCondition()
{
    // Populate a range        
    for (int i=1;i<7;i++)
    {
        Globals.Sheet1.Range["A" + i.ToString()].Value2 
            = i.ToString();
    }

    // Add an icon set condition to the range
    Excel.IconSetCondition iconSetCondition1 = 
        (Excel.IconSetCondition)
        Globals.Sheet1.Range["A1", "A6"].
        FormatConditions.AddIconSetCondition();
    iconSetCondition1.IconSet = 
        this.IconSets[Excel.XlIconSet.xl3Arrows];
}
Private Sub SetIconSetCondition()
    ' Populate a range
    Dim i As Integer
    For i = 1 To 6
        Globals.Sheet1.Range("A" + i.ToString()).Value2 = i.ToString()
    Next

    ' Add an icon set condition to the range
    Dim iconSetCondition1 As Excel.IconSetCondition = _
    Globals.Sheet1.Range("A1", "A6").FormatConditions.AddIconSetCondition()
    iconSetCondition1.IconSet = Me.IconSets(Excel.XlIconSet.xl3Arrows)
End Sub

Remarks

You can use an icon set to classify range data into three to five categories separated by threshold values. Each icon represents a range of values. For example, in the Microsoft.Office.Interop.Excel.XlIconSet.xl3Arrows icon set, the red up arrow represents higher values, the yellow sideways arrow represents middle values, and the green down arrow represents lower values.

To apply a conditional formatting rule based on an icon set, create a new Microsoft.Office.Interop.Excel.IconSetCondition by using the Microsoft.Office.Interop.Excel.FormatConditions.AddIconSetCondition method of the FormatConditions property of a range, or the FormatConditions property of a named range. Then, set the Microsoft.Office.Interop.Excel.IconSetCondition.IconSet property to an Microsoft.Office.Interop.Excel.IconSet object that you retrieve from the IconSets property. To specify the Microsoft.Office.Interop.Excel.IconSet object that you want to retrieve, pass in one of the Microsoft.Office.Interop.Excel.XlIconSet enumeration values as an index to the IconSets property.

Applies to