Syncfusion.XlsIO.Base
Example 


Type dynamic filter

AddDynamicFilter Method

Apply dynamic date filter based on the specified relative date constant.
Syntax
'Declaration
 
Sub AddDynamicFilter( _
   ByVal dynamicFilterType As DynamicFilterType _
) 
'Usage
 
Dim instance As IAutoFilter
Dim dynamicFilterType As DynamicFilterType
 
instance.AddDynamicFilter(dynamicFilterType)
void AddDynamicFilter( 
   DynamicFilterType dynamicFilterType
)

Parameters

dynamicFilterType
Type dynamic filter
Example
The following code illustrates how to apply the ExcelFilterType.DynamicFilter.
using Syncfusion.XlsIO;
using System;
            
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 = "Title";
            worksheet["A2"].Text = "Sales Representative";
            worksheet["A3"].Text = "Sales Agent";
            worksheet["A4"].Text = "Owner";
            worksheet["A5"].Text = "Sales Associate";
            worksheet["A6"].Text = "Sales Representative";
            worksheet["A7"].Text = "Marketing Manager";
            worksheet["B1"].Text = "DOJ";
            worksheet["B2"].DateTime = DateTime.Parse("6/5/2011");
            worksheet["B3"].DateTime = DateTime.Parse("9/5/2011");
            worksheet["B4"].DateTime = DateTime.Parse("10/21/2007");
            worksheet["B5"].DateTime = DateTime.Parse("9/28/2004");
            worksheet["B6"].DateTime = DateTime.Parse("8/28/2007");
            worksheet["B7"].DateTime = DateTime.Parse("8/12/2003");
            
            //Create filters collection
            IAutoFilters filters = worksheet.AutoFilters;
            
            //Set range
            filters.FilterRange = worksheet["A1:C7"];
            
            //Set filter column
            IAutoFilter filter = filters[1];
            
            //Add filter
            filter.AddDynamicFilter(DynamicFilterType.Quarter3);
            
            //Apply AutoFit
            worksheet.UsedRange.AutofitColumns();
            
            //Save and Dispose
            workbook.SaveAs("Filters.xlsx");
            workbook.Close();
        }
    }
}
AssemblyVersion

Syncfusion.XlsIO.Base: 17.2460.0.34

See Also