AutoFilter
Inheritance: java.lang.Object
public class AutoFilter
Represents autofiltering for the specified worksheet.
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");
Methods
addDateFilter(int fieldIndex, int dateTimeGroupingType, int year, int month, int day, int hour, int minute, int second)
public void addDateFilter(int fieldIndex, int dateTimeGroupingType, int year, int month, int day, int hour, int minute, int second)
Adds a date filter.
Remarks
If DateTimeGroupingType is Year, only the param year effects. If DateTiemGroupingType is Month, only the param year and month effect.
Parameters:
Parameter | Type | Description |
---|---|---|
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 | DateTimeGroupingType. 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. |
addFillColorFilter(int fieldIndex, int pattern, CellsColor foregroundColor, CellsColor backgroundColor)
public void addFillColorFilter(int fieldIndex, int pattern, CellsColor foregroundColor, CellsColor backgroundColor)
Adds a fill color filter.
Parameters:
Parameter | Type | Description |
---|---|---|
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 | BackgroundType. The background pattern type. |
foregroundColor | CellsColor | The foreground color. |
backgroundColor | CellsColor | The background color. |
addFilter(int fieldIndex, String criteria)
public void addFilter(int fieldIndex, String criteria)
Adds a filter for a filter column.
Remarks
MS Excel 2007 supports multiple selection in a filter column.
Parameters:
Parameter | Type | Description |
---|---|---|
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 | java.lang.String | The specified criteria (a string; for example, “101”). It only can be null or be one of the cells’ value in this column. |
addFontColorFilter(int fieldIndex, CellsColor color)
public void addFontColorFilter(int fieldIndex, CellsColor color)
Adds a font color filter.
Parameters:
Parameter | Type | Description |
---|---|---|
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. |
addIconFilter(int fieldIndex, int iconSetType, int iconId)
public void addIconFilter(int fieldIndex, int iconSetType, int iconId)
Adds an icon filter.
Remarks
Only supports to add the icon filter. Not supports checking which row is visible if the filter is icon filter.
Parameters:
Parameter | Type | Description |
---|---|---|
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 | IconSetType. The icon set type. |
iconId | int | The icon id. |
custom(int fieldIndex, int operatorType1, Object criteria1)
public void custom(int fieldIndex, int operatorType1, Object criteria1)
Filters a list with a custom criteria.
Parameters:
Parameter | Type | Description |
---|---|---|
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 | FilterOperatorType. The filter operator type |
criteria1 | java.lang.Object | The custom criteria |
custom(int fieldIndex, int operatorType1, Object criteria1, boolean isAnd, int operatorType2, Object criteria2)
public void custom(int fieldIndex, int operatorType1, Object criteria1, boolean isAnd, int operatorType2, Object criteria2)
Filters a list with custom criteria.
Parameters:
Parameter | Type | Description |
---|---|---|
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 | FilterOperatorType. The filter operator type |
criteria1 | java.lang.Object | The custom criteria |
isAnd | boolean | |
operatorType2 | int | FilterOperatorType. The filter operator type |
criteria2 | java.lang.Object | The custom criteria |
dynamicFilter(int fieldIndex, int dynamicFilterType)
public void dynamicFilter(int fieldIndex, int dynamicFilterType)
Adds a dynamic filter.
Parameters:
Parameter | Type | Description |
---|---|---|
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 | DynamicFilterType. Dynamic filter type. |
equals(Object arg0)
public boolean equals(Object arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | java.lang.Object |
Returns: boolean
filter(int fieldIndex, String criteria)
public void filter(int fieldIndex, String criteria)
Filters a list with specified criteria.
Remarks
Aspose.Cells will remove all other filter setting on this field as Ms Excel 97-2003.
Parameters:
Parameter | Type | Description |
---|---|---|
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 | java.lang.String | The specified criteria (a string; for example, “101”). |
filterTop10(int fieldIndex, boolean isTop, boolean isPercent, int itemCount)
public void filterTop10(int fieldIndex, boolean isTop, boolean isPercent, int itemCount)
Filter the top 10 item in the list
Parameters:
Parameter | Type | Description |
---|---|---|
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 |
getCellArea()
public CellArea getCellArea()
Gets the CellArea where the specified AutoFilter applies to.
Returns: CellArea -
getClass()
public final native Class<?> getClass()
Returns: java.lang.Class
getFilterColumns()
public FilterColumnCollection getFilterColumns()
Gets the collection of the filter columns.
Returns: FilterColumnCollection
getRange()
public String getRange()
Represents the range to which the specified AutoFilter applies.
Returns: java.lang.String
getShowFilterButton()
public boolean getShowFilterButton()
Indicates whether the AutoFilter button for this column is visible.
Returns: boolean
getSorter()
public DataSorter getSorter()
Gets the data sorter.
Returns: DataSorter
hashCode()
public native int hashCode()
Returns: int
matchBlanks(int fieldIndex)
public void matchBlanks(int fieldIndex)
Match all blank cell in the list.
Parameters:
Parameter | Type | Description |
---|---|---|
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(int fieldIndex)
public void matchNonBlanks(int fieldIndex)
Match all not blank cell in the list.
Parameters:
Parameter | Type | Description |
---|---|---|
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). |
notify()
public final native void notify()
notifyAll()
public final native void notifyAll()
refresh()
public int[] refresh()
Refresh auto filters to hide or unhide the rows.
Returns: int[] - Returns all hidden rows’ indexes.
refresh(boolean hideRows)
public int[] refresh(boolean hideRows)
Gets all hidden rows’ indexes.
Parameters:
Parameter | Type | Description |
---|---|---|
hideRows | boolean | If true, hide the filtered rows. |
Returns: int[] - Returns all hidden rows indexes.
removeDateFilter(int fieldIndex, int dateTimeGroupingType, int year, int month, int day, int hour, int minute, int second)
public void removeDateFilter(int fieldIndex, int dateTimeGroupingType, int year, int month, int day, int hour, int minute, int second)
Removes a date filter.
Remarks
If DateTimeGroupingType is Year, only the param year effects. If DateTiemGroupingType is Month, only the param year and month effect.
Parameters:
Parameter | Type | Description |
---|---|---|
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 | DateTimeGroupingType. 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(int fieldIndex)
public void removeFilter(int fieldIndex)
Remove the specific filter.
Parameters:
Parameter | Type | Description |
---|---|---|
fieldIndex | int | The specific filter index |
removeFilter(int fieldIndex, String criteria)
public void removeFilter(int fieldIndex, String criteria)
Removes a filter for a filter column.
Parameters:
Parameter | Type | Description |
---|---|---|
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 | java.lang.String | The specified criteria (a string; for example, “101”). It only can be null or be one of the cells’ value in this column. |
setRange(int row, int startColumn, int endColumn)
public void setRange(int row, int startColumn, int endColumn)
Sets the range to which the specified AutoFilter applies.
Parameters:
Parameter | Type | Description |
---|---|---|
row | int | Row index. |
startColumn | int | Start column index. |
endColumn | int | End column Index. |
setRange(String value)
public void setRange(String value)
Represents the range to which the specified AutoFilter applies.
Parameters:
Parameter | Type | Description |
---|---|---|
value | java.lang.String |
setShowFilterButton(boolean value)
public void setShowFilterButton(boolean value)
Indicates whether the AutoFilter button for this column is visible.
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
showAll()
public void showAll()
Unhide all rows.
toString()
public String toString()
Returns: java.lang.String
wait()
public final void wait()
wait(long arg0)
public final native void wait(long arg0)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long |
wait(long arg0, int arg1)
public final void wait(long arg0, int arg1)
Parameters:
Parameter | Type | Description |
---|---|---|
arg0 | long | |
arg1 | int |