public class AutoFilter
extends java.lang.Object
Example
//Creating a file stream containing the Excel file to be opened
//Instantiating a Workbook object
Workbook workbook = new Workbook("template.xlsx");
//Accessing the first worksheet in the Excel file
Worksheet 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("output.xls");
| Modifier and Type | Method and Description |
|---|---|
void |
addDateFilter(int fieldIndex,
int dateTimeGroupingType,
int year,
int month,
int day,
int hour,
int minute,
int second)
Adds a date filter.
|
void |
addFillColorFilter(int fieldIndex,
int pattern,
CellsColor foregroundColor,
CellsColor backgroundColor)
Adds a fill color filter.
|
void |
addFilter(int fieldIndex,
java.lang.String criteria)
Adds a filter for a filter column.
|
void |
addFontColorFilter(int fieldIndex,
CellsColor color)
Adds a font color filter.
|
void |
addIconFilter(int fieldIndex,
int iconSetType,
int iconId)
Adds an icon filter.
|
void |
custom(int fieldIndex,
int operatorType1,
java.lang.Object criteria1)
Filters a list with a custom criteria.
|
void |
custom(int fieldIndex,
int operatorType1,
java.lang.Object criteria1,
boolean isAnd,
int operatorType2,
java.lang.Object criteria2)
Filters a list with custom criteria.
|
void |
dynamicFilter(int fieldIndex,
int dynamicFilterType)
Adds a dynamic filter.
|
void |
filter(int fieldIndex,
java.lang.String criteria)
Filters a list with specified criteria.
|
void |
filterTop10(int fieldIndex,
boolean isTop,
boolean isPercent,
int itemCount)
Filter the top 10 item in the list
|
CellArea |
getCellArea()
Gets the
CellArea where the this AutoFilter applies to. |
CellArea |
getCellArea(boolean refreshAppliedRange)
Gets the
CellArea where the specified AutoFilter applies to. |
FilterColumnCollection |
getFilterColumns()
Gets the collection of the filter columns.
|
java.lang.String |
getRange()
Represents the range to which the specified AutoFilter applies.
|
boolean |
getShowFilterButton()
Indicates whether the AutoFilter button for this column is visible.
|
DataSorter |
getSorter()
Gets the data sorter.
|
void |
matchBlanks(int fieldIndex)
Match all blank cell in the list.
|
void |
matchNonBlanks(int fieldIndex)
Match all not blank cell in the list.
|
int[] |
refresh()
Refresh auto filters to hide or unhide the rows.
|
int[] |
refresh(boolean hideRows)
Gets all hidden rows' indexes.
|
void |
removeDateFilter(int fieldIndex,
int dateTimeGroupingType,
int year,
int month,
int day,
int hour,
int minute,
int second)
Removes a date filter.
|
void |
removeFilter(int fieldIndex)
Remove the specific filter.
|
void |
removeFilter(int fieldIndex,
java.lang.String criteria)
Removes a filter for a filter column.
|
void |
setRange(int row,
int startColumn,
int endColumn)
Sets the range to which the specified AutoFilter applies.
|
void |
setRange(java.lang.String value)
Represents the range to which the specified AutoFilter applies.
|
void |
setShowFilterButton(boolean value)
Indicates whether the AutoFilter button for this column is visible.
|
void |
showAll()
Unhide all rows.
|
public DataSorter getSorter()
public void setRange(int row,
int startColumn,
int endColumn)
row - Row index.startColumn - Start column index.endColumn - End column Index.public CellArea getCellArea()
CellArea where the this AutoFilter applies to.public CellArea getCellArea(boolean refreshAppliedRange)
CellArea where the specified AutoFilter applies to.refreshAppliedRange - Whether refresh the applied range.
For the applied range of auto filter, the last row may change when cells data changes.
If this flag is true, then the last row of the range will be re-calculated according to current cells data.public java.lang.String getRange()
public void setRange(java.lang.String value)
public void addFilter(int fieldIndex,
java.lang.String criteria)
Remarks
MS Excel 2007 supports multiple selection in a filter column.fieldIndex - 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 - The specified criteria (a string; for example, "101").
It only can be null or be one of the cells' value in this column.public void addDateFilter(int fieldIndex,
int dateTimeGroupingType,
int year,
int month,
int day,
int hour,
int minute,
int second)
Remarks
If DateTimeGroupingType is Year, only the param year effects. If DateTiemGroupingType is Month, only the param year and month effect.fieldIndex - 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 - DateTimeGroupingType. The grouping typeyear - The year.month - The month.day - The day.hour - The hour.minute - The minute.second - The second.public void removeDateFilter(int fieldIndex,
int dateTimeGroupingType,
int year,
int month,
int day,
int hour,
int minute,
int second)
Remarks
If DateTimeGroupingType is Year, only the param year effects. If DateTiemGroupingType is Month, only the param year and month effect.fieldIndex - 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 - DateTimeGroupingType. The grouping typeyear - The year.month - The month.day - The day.hour - The hour.minute - The minute.second - The second.public void removeFilter(int fieldIndex,
java.lang.String criteria)
fieldIndex - 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 - The specified criteria (a string; for example, "101").
It only can be null or be one of the cells' value in this column.public void filter(int fieldIndex,
java.lang.String criteria)
Remarks
Aspose.Cells will remove all other filter setting on this field as Ms Excel 97-2003.fieldIndex - 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 - The specified criteria (a string; for example, "101").public void filterTop10(int fieldIndex,
boolean isTop,
boolean isPercent,
int itemCount)
fieldIndex - 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 - Indicates whether filter from top or bottomisPercent - Indicates whether the items is percent or countitemCount - The item countpublic void dynamicFilter(int fieldIndex,
int dynamicFilterType)
fieldIndex - 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 - DynamicFilterType.
Dynamic filter type.public void addFontColorFilter(int fieldIndex,
CellsColor color)
fieldIndex - 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 - The CellsColor object.public void addFillColorFilter(int fieldIndex,
int pattern,
CellsColor foregroundColor,
CellsColor backgroundColor)
fieldIndex - 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 - BackgroundType. The background pattern type.foregroundColor - The foreground color.backgroundColor - The background color.public void addIconFilter(int fieldIndex,
int iconSetType,
int iconId)
Remarks
Only supports to add the icon filter. Not supports checking which row is visible if the filter is icon filter.fieldIndex - 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 - IconSetType. The icon set type.iconId - The icon id.public void matchBlanks(int fieldIndex)
fieldIndex - 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).public void matchNonBlanks(int fieldIndex)
fieldIndex - 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).public void custom(int fieldIndex,
int operatorType1,
java.lang.Object criteria1)
fieldIndex - 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 - FilterOperatorType. The filter operator typecriteria1 - The custom criteriapublic void custom(int fieldIndex,
int operatorType1,
java.lang.Object criteria1,
boolean isAnd,
int operatorType2,
java.lang.Object criteria2)
fieldIndex - 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 - FilterOperatorType. The filter operator typecriteria1 - The custom criteriaisAnd - operatorType2 - FilterOperatorType. The filter operator typecriteria2 - The custom criteriapublic void showAll()
public void removeFilter(int fieldIndex)
fieldIndex - The specific filter indexpublic int[] refresh()
public int[] refresh(boolean hideRows)
hideRows - If true, hide the filtered rows.public boolean getShowFilterButton()
public void setShowFilterButton(boolean value)
public FilterColumnCollection getFilterColumns()
See Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.