Syncfusion.XlsIO.Base
Example 


ExcelIconSetType to be filtered from.
IconId to be filtered.

AddIconFilter Method

Apply Icon Filter with the specfied iconId for the Iconset applied.
Syntax
'Declaration
 
Sub AddIconFilter( _
   ByVal iconSetType As ExcelIconSetType, _
   ByVal iconId As Integer _
) 
'Usage
 
Dim instance As IAutoFilter
Dim iconSetType As ExcelIconSetType
Dim iconId As Integer
 
instance.AddIconFilter(iconSetType, iconId)
void AddIconFilter( 
   ExcelIconSetType iconSetType,
   int iconId
)

Parameters

iconSetType
ExcelIconSetType to be filtered from.
iconId
IconId to be filtered.
Remarks
To apply filters within tables in worksheet, we have to set the IAutoFilters as child of IListObject. The range for the IAutoFilters will be same as the IListObject.Location.
Example
Iconsets can be applied by setting conditional formats for data in the worksheet. For the iconsets applied using conditional formats we can apply ExcelFilterType.IconFilter to filter a particular icon based on it's id or index. Here for example, we set ExcelIconSetType.ThreeArrows using conditional formats and filter the first icon in it.
using Syncfusion.XlsIO;
            
class Program
{
    static void Main()
    {
        using (ExcelEngine excelEngine = new ExcelEngine())
        {
            //Create worksheet
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];
            
            //Load data
            worksheet["A1"].Text = "Products";
            worksheet["A2"].Text = "Alfreds Futterkiste";
            worksheet["A3"].Text = "Antonio Moreno Taqueria";
            worksheet["A4"].Text = "Around the Horn";
            worksheet["A5"].Text = "Bon app";
            worksheet["A6"].Text = "Eastern Connection";
            worksheet["A7"].Text = "Ernst Handel";
            worksheet["B1"].Text = "Qtr1";
            worksheet["B2"].Number = 144.6;
            worksheet["B3"].Number = 579.6;
            worksheet["B4"].Number = 267.5;
            worksheet["B5"].Number = 418;
            worksheet["B6"].Number = 728;
            worksheet["B7"].Number = 943.89;
            worksheet["C1"].Text = "Qtr2";
            worksheet["C2"].Number = 162.56;
            worksheet["C3"].Number = 1249.2;
            worksheet["C4"].Number = 1062.5;
            worksheet["C5"].Number = 756;
            worksheet["C6"].Number = 4547.92;
            worksheet["C7"].Number = 349.6;
            
            //Create style for table number format
            IStyle style1 = workbook.Styles.Add("CurrencyFormat");
            style1.NumberFormat = "_($* #,##0.00_);_($* (#,##0.00);_($* \" - \"??_);_(@_)";
            
            //Apply number format
            worksheet["B2:C7"].CellStyleName = "CurrencyFormat";
            
            //Create filters collection
            IAutoFilters filters = worksheet.AutoFilters;
            
            //Set range
            filters.FilterRange = worksheet["A1:C7"];
            
            //Set filter column
            IAutoFilter filter = filters[1];
            
            //Create conditional formats
            IConditionalFormats formats = worksheet["B2:B7"].ConditionalFormats;
            IConditionalFormat format = formats.AddCondition();
            
            //Set Type as IconSet
            format.FormatType = ExcelCFType.IconSet;
            
            //Add filter
            filter.AddIconFilter(ExcelIconSetType.ThreeArrows, 0);
            
            //Apply AutoFit
            worksheet.UsedRange.AutofitColumns();
            
            //Save and Dispose
            workbook.SaveAs("Filters.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.2460.0.34

See Also