AutoFilterImpl Class
This class represents single autofilter item.
Inheritance
Inherited Members
Namespace: Syncfusion.XlsIO.Implementation
Assembly: Syncfusion.XlsIO.Base.dll
Syntax
public class AutoFilterImpl : IAutoFilter, ICloneParent
Properties
FilteredItems
Returns filter values for combination type ( Text and DateTime), dynamic and color type. It returns null, if custom filter is applied. Read-only.
Declaration
public IFilter FilteredItems { get; }
Property Value
Type |
---|
IFilter |
FilterType
Specifies the type of filter.
Declaration
public ExcelFilterType FilterType { get; set; }
Property Value
Type |
---|
ExcelFilterType |
FirstCondition
First condition of autofilter. Read-only.
Declaration
public IAutoFilterCondition FirstCondition { get; }
Property Value
Type |
---|
IAutoFilterCondition |
Index
Number of AutoFilter drop-down arrows on the sheet. ( One based )
Declaration
public int Index { get; set; }
Property Value
Type |
---|
System.Int32 |
IsAnd
True means to use AND operation between conditions, False to use OR.
Declaration
public bool IsAnd { get; set; }
Property Value
Type |
---|
System.Boolean |
IsBlanks
If filtered to blanks - true. Read-only.
Declaration
public bool IsBlanks { get; }
Property Value
Type |
---|
System.Boolean |
IsFiltered
False indicates that this autofilter was not used; otherwise True.
Declaration
public bool IsFiltered { get; }
Property Value
Type |
---|
System.Boolean |
IsFirstCondition
If true - than contain non default first condition; otherwise false. Read-only.
Declaration
public bool IsFirstCondition { get; }
Property Value
Type |
---|
System.Boolean |
IsNonBlanks
If filtered to nonblanks - true. Read-only.
Declaration
public bool IsNonBlanks { get; }
Property Value
Type |
---|
System.Boolean |
IsPercent
True if the Top 10 AutoFilter shows percentage; False if it shows items.
Declaration
public bool IsPercent { get; set; }
Property Value
Type |
---|
System.Boolean |
IsSecondCondition
If true - than contain non default second condition; otherwise false. Read-only.
Declaration
public bool IsSecondCondition { get; }
Property Value
Type |
---|
System.Boolean |
IsSimple1
True if the first condition is a simple equality.
Declaration
public bool IsSimple1 { get; set; }
Property Value
Type |
---|
System.Boolean |
IsSimple2
True if the second condition is a simple equality.
Declaration
public bool IsSimple2 { get; set; }
Property Value
Type |
---|
System.Boolean |
IsTop
True if the Top 10 AutoFilter shows the top items; False if it shows the bottom items.
Declaration
public bool IsTop { get; set; }
Property Value
Type |
---|
System.Boolean |
IsTop10
True if the condition is a Top 10 AutoFilter.
Declaration
public bool IsTop10 { get; set; }
Property Value
Type |
---|
System.Boolean |
SecondCondition
Second condition of autofilter. Read-only.
Declaration
public IAutoFilterCondition SecondCondition { get; }
Property Value
Type |
---|
IAutoFilterCondition |
Top10Number
Number of elements to show in Top10 mode.
Declaration
public int Top10Number { get; set; }
Property Value
Type |
---|
System.Int32 |
Worksheet
Returns parent worksheet. Read-only.
Declaration
public WorksheetImpl Worksheet { get; }
Property Value
Type |
---|
WorksheetImpl |
WorksheetShapes
Returns shapes collection of the parent worksheet. Read-only.
Declaration
public ShapesCollection WorksheetShapes { get; }
Property Value
Type |
---|
Syncfusion.XlsIO.Implementation.Collections.ShapesCollection |
Methods
AddColorFilter(Color, ExcelColorFilterType)
Add Color Filter with the specified System.Drawing.Color object
Declaration
public void AddColorFilter(Color color, ExcelColorFilterType colorFilterType)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Color | color | Color to be filtered. |
ExcelColorFilterType | colorFilterType | Filter type applied. |
Examples
The following code illustrates the filtering cells based on cell color
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Open("ColorFilter.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
worksheet.AutoFilters.FilterRange = worksheet["A1:C30"];
IAutoFilter filter = worksheet.AutoFilters[1];
filter.AddColorFilter(ExcelColorFilterType.CellColor, System.Drawing.Color.Red);
workbook.SaveAs("FilteredbyColorFilter.xlsx");
workbook.Close();
excelEngine.Dispose();
The following code illustrates the filtering cells based on Font color
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Open("ColorFilter.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
worksheet.AutoFilters.FilterRange = worksheet["A1:C30"];
IAutoFilter filter = worksheet.AutoFilters[1];
filter.AddColorFilter(System.Drawing.Color.Red, ExcelColorFilterType.FontColor);
workbook.SaveAs("FilteredbyColorFilter.xlsx");
workbook.Close();
excelEngine.Dispose();
AddDateFilter(DateTime, DateTimeGroupingType)
Apply DateTime filter with the specified date time.
Declaration
public void AddDateFilter(DateTime dateTime, DateTimeGroupingType groupingType)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dateTime | Date with time which need to add. |
DateTimeGroupingType | groupingType | Type of grouping. |
AddDateFilter(Int32, Int32, Int32, Int32, Int32, Int32, DateTimeGroupingType)
Apply DateTime filter with the specified date time.
Declaration
public void AddDateFilter(int year, int month, int day, int hour, int mintue, int second, DateTimeGroupingType groupingType)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | year | year in the date time. |
System.Int32 | month | month in the date time. |
System.Int32 | day | day in the date time. |
System.Int32 | hour | hour in the date time. |
System.Int32 | mintue | mintue in the date time. |
System.Int32 | second | Seconds in the date time. |
DateTimeGroupingType | groupingType | With respective grouping type. |
AddDynamicFilter(DynamicFilterType)
Apply dynamic date filter based on the specified relative date constant.
Declaration
public void AddDynamicFilter(DynamicFilterType dateFilterType)
Parameters
Type | Name | Description |
---|---|---|
DynamicFilterType | dateFilterType | Dynamic filer type. |
AddIconFilter(ExcelIconSetType, Int32)
Apply Icon Filter with the specfied iconId for the Iconset applied.
Declaration
public void AddIconFilter(ExcelIconSetType iconSetType, int iconId)
Parameters
Type | Name | Description |
---|---|---|
ExcelIconSetType | iconSetType | IconSetType to be filtered from. |
System.Int32 | iconId | IconId to be filtered. |
Examples
The following code illustrates applying icon filter based on the icon present in the cell.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Open("IconFilter.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
IConditionalFormats formats = worksheet["B1:B15"].ConditionalFormats;
IConditionalFormat format = formats.AddCondition();
format.BackColorRGB = System.Drawing.Color.Red;
format.FormatType = ExcelCFType.IconSet;
format.IconSet.IconSet = ExcelIconSetType.ThreeArrows;
worksheet.AutoFilters.FilterRange = worksheet["A1:C30"];
IAutoFilter filter = worksheet.AutoFilters[1];
filter.AddIconFilter(ExcelIconSetType.ThreeArrows, 1);
workbook.SaveAs("FilteredBook.xlsx");
workbook.Close();
excelEngine.Dispose();
AddTextFilter(IEnumerable<String>)
Apply text filter with the specified string collection.
Declaration
public void AddTextFilter(IEnumerable<string> filterCollection)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | filterCollection | IEnumerable collection of string |
AddTextFilter(String)
Apply text filter with the specified string.
Declaration
public void AddTextFilter(string filter)
Parameters
Type | Name | Description |
---|---|---|
System.String | filter | string value need to add in the text filter |
Clear()
Clears content of the autofilter (shape corresponding to autofilter).
Declaration
public void Clear()
Clone(Object)
Clone current instance.
Declaration
public object Clone(object parent)
Parameters
Type | Name | Description |
---|---|---|
System.Object | parent | Parent object. |
Returns
Type | Description |
---|---|
System.Object | Returns just created object. |
RemoveColorFilter()
Clears the applied color filter in the particular column
Declaration
public void RemoveColorFilter()
RemoveDate(DateTime, DateTimeGroupingType)
Remove specified date time from DateTime filter.
Declaration
public bool RemoveDate(DateTime dateTime, DateTimeGroupingType groupingType)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dateTime | Datetime which need to remove. |
DateTimeGroupingType | groupingType | With respective grouping type |
Returns
Type | Description |
---|---|
System.Boolean | Return true if the value is removed, else false. |
RemoveDate(Int32, Int32, Int32, Int32, Int32, Int32, DateTimeGroupingType)
Remove specified date time from DateTime filter.
Declaration
public bool RemoveDate(int year, int month, int day, int hour, int mintue, int second, DateTimeGroupingType groupingType)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | year | year in the date time. |
System.Int32 | month | month in the date time. |
System.Int32 | day | day in the date time. |
System.Int32 | hour | hour in the date time. |
System.Int32 | mintue | mintue in the date time. |
System.Int32 | second | Seconds in the date time. |
DateTimeGroupingType | groupingType | With respective grouping type. |
Returns
Type | Description |
---|---|
System.Boolean | Return true if the value is removed, else false. |
RemoveDynamicFilter()
Remove dynamic date filter if exist.
Declaration
public bool RemoveDynamicFilter()
Returns
Type | Description |
---|---|
System.Boolean | Return true if the value is removed, else false. |
RemoveIconFilter()
Removes the IconFilter (If applied).
Declaration
public void RemoveIconFilter()
RemoveText(IEnumerable<String>)
Declaration
public bool RemoveText(IEnumerable<string> filterCollection)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | filterCollection |
Returns
Type |
---|
System.Boolean |
RemoveText(String)
Remove text value in text filter with the specified string.
Declaration
public bool RemoveText(string filter)
Parameters
Type | Name | Description |
---|---|---|
System.String | filter | String Value that have to remove from the Text filter. |
Returns
Type | Description |
---|---|
System.Boolean | Return true if the value is removed, else false. |