Freigeben über


WorkbookBase.IconSets Property

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

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v4.0.Utilities (in Microsoft.Office.Tools.Excel.v4.0.Utilities.dll)

Syntax

'Declaration
Public ReadOnly Property IconSets As IconSets
public IconSets IconSets { get; }

Property Value

Type: Microsoft.Office.Interop.Excel.IconSets
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.

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.

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 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
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];
}

.NET Framework Security

See Also

Reference

WorkbookBase Class

Microsoft.Office.Tools.Excel Namespace