asposecells.api

Class AutoFilter

Represents autofiltering for the specified worksheet.

Example:

# Instantiating a Workbook object
workbook = Workbook("Book2.xlsx")
# Accessing the first worksheet in the Excel file
worksheet = workbook.getWorksheets().get(0)
# Creating AutoFilter by giving the cells range of the heading row
worksheet.getAutoFilter().setRange("A1:B1")
# Filtering columns with specified values
worksheet.getAutoFilter().filter(1, "Bananas")
# Saving the modified Excel file.
workbook.save("Book2.xls")

Property Getters/Setters Summary
methodgetFilterColumns()
Gets the collection of the filter columns.
methodgetRange()
method
setRange(value)
           Represents the range to which the specified AutoFilter applies.
methodgetShowFilterButton()
method
           Indicates whether the AutoFilter button for this column is visible.
methodgetSorter()
Gets the data sorter.
 
Method Summary
methodaddDateFilter(fieldIndex, dateTimeGroupingType, year, month, day, hour, minute, second)
Adds a date filter.
methodaddFillColorFilter(fieldIndex, pattern, foregroundColor, backgroundColor)
Adds a fill color filter.
methodaddFilter(fieldIndex, criteria)
Adds a filter for a filter column.
methodaddFontColorFilter(fieldIndex, color)
Adds a font color filter.
methodaddIconFilter(fieldIndex, iconSetType, iconId)
Adds an icon filter.
methodcustom(fieldIndex, operatorType1, criteria1)
Filters a list with a custom criteria.
methodcustom(fieldIndex, operatorType1, criteria1, isAnd, operatorType2, criteria2)
Filters a list with custom criteria.
methoddynamicFilter(fieldIndex, dynamicFilterType)
Adds a dynamic filter.
methodfilter(fieldIndex, criteria)
Filters a list with specified criteria.
methodfilterTop10(fieldIndex, isTop, isPercent, itemCount)
Filter the top 10 item in the list
methodgetCellArea()
Gets the CellArea where the specified AutoFilter applies to.
methodmatchBlanks(fieldIndex)
Match all blank cell in the list.
methodmatchNonBlanks(fieldIndex)
Match all not blank cell in the list.
methodrefresh()
Refresh auto filters to hide or unhide the rows.
methodrefresh(hideRows)
Gets all hidden rows' indexes.
methodremoveDateFilter(fieldIndex, dateTimeGroupingType, year, month, day, hour, minute, second)
Removes a date filter.
methodremoveFilter(fieldIndex)
Remove the specific filter.
methodremoveFilter(fieldIndex, criteria)
Removes a filter for a filter column.
methodsetRange(row, startColumn, endColumn)
Sets the range to which the specified AutoFilter applies.
methodshowAll()
Unhide all rows.
 

    • Property Getters/Setters Detail

      • getRange/setRange : String 

        String getRange() / setRange(value)
        
        Represents the range to which the specified AutoFilter applies.
      • getShowFilterButton/setShowFilterButton : boolean 

        boolean getShowFilterButton() / setShowFilterButton(value)
        
        Indicates whether the AutoFilter button for this column is visible.
    • Method Detail

      • setRange

         setRange(row, startColumn, endColumn)
        Sets the range to which the specified AutoFilter applies.
        Parameters:
        row: int - Row index.
        startColumn: int - Start column index.
        endColumn: int - End column Index.
      • getCellArea

        CellArea getCellArea()
        Gets the CellArea where the specified AutoFilter applies to.
        Returns:
      • addFilter

         addFilter(fieldIndex, criteria)
        Adds a filter for a filter column. MS Excel 2007 supports multiple selection in a filter column.
        Parameters:
        fieldIndex: int - The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field 0).
        criteria: String - The specified criteria (a string; for example, "101"). It only can be null or be one of the cells' value in this column.
      • addDateFilter

         addDateFilter(fieldIndex, dateTimeGroupingType, year, month, day, hour, minute, second)
        Adds a date filter. If DateTimeGroupingType is Year, only the param year effects. If DateTiemGroupingType is Month, only the param year and month effect.
        Parameters:
        fieldIndex: int - The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field 0).
        dateTimeGroupingType: int - A DateTimeGroupingType value. The grouping type
        year: int - The year.
        month: int - The month.
        day: int - The day.
        hour: int - The hour.
        minute: int - The minute.
        second: int - The second.
      • removeDateFilter

         removeDateFilter(fieldIndex, dateTimeGroupingType, year, month, day, hour, minute, second)
        Removes a date filter. If DateTimeGroupingType is Year, only the param year effects. If DateTiemGroupingType is Month, only the param year and month effect.
        Parameters:
        fieldIndex: int - The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field 0).
        dateTimeGroupingType: int - A DateTimeGroupingType value. The grouping type
        year: int - The year.
        month: int - The month.
        day: int - The day.
        hour: int - The hour.
        minute: int - The minute.
        second: int - The second.
      • removeFilter

         removeFilter(fieldIndex, criteria)
        Removes a filter for a filter column.
        Parameters:
        fieldIndex: int - The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field 0).
        criteria: String - The specified criteria (a string; for example, "101"). It only can be null or be one of the cells' value in this column.
      • filter

         filter(fieldIndex, criteria)
        Filters a list with specified criteria. Aspose.Cells will remove all other filter setting on this field as Ms Excel 97-2003.
        Parameters:
        fieldIndex: int - The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field 0).
        criteria: String - The specified criteria (a string; for example, "101").
      • filterTop10

         filterTop10(fieldIndex, isTop, isPercent, itemCount)
        Filter the top 10 item in the list
        Parameters:
        fieldIndex: int - The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field 0).
        isTop: boolean - Indicates whether filter from top or bottom
        isPercent: boolean - Indicates whether the items is percent or count
        itemCount: int - The item count
      • dynamicFilter

         dynamicFilter(fieldIndex, dynamicFilterType)
        Adds a dynamic filter.
        Parameters:
        fieldIndex: int - The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field 0).
        dynamicFilterType: int - A DynamicFilterType value. Dynamic filter type.
      • addFontColorFilter

         addFontColorFilter(fieldIndex, color)
        Adds a font color filter.
        Parameters:
        fieldIndex: int - The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field 0).
        color: CellsColor - The CellsColor object.
      • addFillColorFilter

         addFillColorFilter(fieldIndex, pattern, foregroundColor, backgroundColor)
        Adds a fill color filter.
        Parameters:
        fieldIndex: int - The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field 0).
        pattern: int - A BackgroundType value. The background pattern type.
        foregroundColor: CellsColor - The foreground color.
        backgroundColor: CellsColor - The background color.
      • addIconFilter

         addIconFilter(fieldIndex, iconSetType, iconId)
        Adds an icon filter. Only supports to add the icon filter. Not supports checking which row is visible if the filter is icon filter.
        Parameters:
        fieldIndex: int - The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field 0).
        iconSetType: int - A IconSetType value. The icon set type.
        iconId: int - The icon id.
      • matchBlanks

         matchBlanks(fieldIndex)
        Match all blank cell in the list.
        Parameters:
        fieldIndex: int - The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field 0).
      • matchNonBlanks

         matchNonBlanks(fieldIndex)
        Match all not blank cell in the list.
        Parameters:
        fieldIndex: int - The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field 0).
      • custom

         custom(fieldIndex, operatorType1, criteria1)
        Filters a list with a custom criteria.
        Parameters:
        fieldIndex: int - The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field 0).
        operatorType1: int - A FilterOperatorType value. The filter operator type
        criteria1: Object - The custom criteria
      • custom

         custom(fieldIndex, operatorType1, criteria1, isAnd, operatorType2, criteria2)
        Filters a list with custom criteria.
        Parameters:
        fieldIndex: int - The integer offset of the field on which you want to base the filter (from the left of the list; the leftmost field is field 0).
        operatorType1: int - A FilterOperatorType value. The filter operator type
        criteria1: Object - The custom criteria
        isAnd: boolean -
        operatorType2: int - A FilterOperatorType value. The filter operator type
        criteria2: Object - The custom criteria
      • showAll

         showAll()
        Unhide all rows.
      • removeFilter

         removeFilter(fieldIndex)
        Remove the specific filter.
        Parameters:
        fieldIndex: int - The specific filter index
      • refresh

        int[] refresh()
        Refresh auto filters to hide or unhide the rows.
        Returns:
        Returns all hidden rows' indexes.
      • refresh

        int[] refresh(hideRows)
        Gets all hidden rows' indexes.
        Parameters:
        hideRows: boolean - If true, hide the filtered rows.
        Returns:
        Returns all hidden rows indexes.