AutoFilter Class
Represents autofiltering for the specified worksheet.
Inheritance Hierarchy
SystemObject
  Aspose.CellsAutoFilter

Namespace: Aspose.Cells
Assembly: Aspose.Cells (in Aspose.Cells.dll) Version: 19.11.0.0 (19.11)
Syntax
public class AutoFilter

The AutoFilter type exposes the following members.

Properties
  NameDescription
Public propertyFilterColumns
Gets the collection of the filter columns.
Public propertyRange
Represents the range to which the specified AutoFilter applies.
Public propertySorter
Gets the data sorter.
Methods
  NameDescription
Public methodAddDateFilter
Adds a date filter.
Public methodAddFillColorFilter
Adds a fill color filter.
Public methodAddFilter
Adds a filter for a filter column.
Public methodAddFontColorFilter
Adds a font color filter.
Public methodAddIconFilter
Adds an icon filter.
Public methodCustom(Int32, FilterOperatorType, Object)
Filters a list with a custom criteria.
Public methodCustom(Int32, FilterOperatorType, Object, Boolean, FilterOperatorType, Object)
Filters a list with custom criteria.
Public methodDynamicFilter
Adds a dynamic filter.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodFilter
Filters a list with specified criteria.
Public methodFilterTop10
Filter the top 10 item in the list
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Public methodMatchBlanks
Match all blank cell in the list.
Public methodMatchNonBlanks
Match all not blank cell in the list.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodRefresh
Refresh auto filters to hide or unhide the rows.
Public methodRefresh(Boolean)
Gets all hidden rows's indexes.
Public methodRemoveDateFilter
Removes a date filter.
Public methodRemoveFilter(Int32)
Remove the specific filter.
Public methodRemoveFilter(Int32, String)
Removes a filter for a filter column.
Public methodSetRange
Sets the range to which the specified AutoFilter applies.
Public methodShowAll
Unhide all rows.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Examples
[C#]

//Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream("C:\\book1.xls", FileMode.Open);
//Instantiating a Workbook object and open a stream.
Workbook workbook = new Workbook(fstream);
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets[0];
//Creating AutoFilter by giving the cells range of the heading row
worksheet.AutoFilter.Range = "A1:B1";
//Filtering columns with specified values
worksheet.AutoFilter.Filter(1, "Bananas");
//Saving the modified Excel file.
workbook.Save("C:\\output.xls");
//Closing the file stream to free all resources
fstream.Close();

[Visual Basic]

'Creating a file stream containing the Excel file to be opened
Dim fstream As FileStream = New FileStream("C:\\book1.xls", FileMode.Open)
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook(fstream)
'Accessing the first worksheet in the Excel file
Dim worksheet As Worksheet = workbook.Worksheets(0)
'Creating AutoFilter by giving the cells range of the heading row
worksheet.AutoFilter.Range = "A1:B1"
'Filtering columns with specified values
Worksheet.AutoFilter.Filter(1, "Bananas")
'Saving the modified Excel file 
workbook.Save("C:\\output.xls")
'Closing the file stream to free all resources
fstream.Close()
See Also