Filter Data
Working with Filters
Use the worksheet AddAutoFilter method to enable auto-filter for a worksheet. This method accepts the row, start and end column indexes.
To enable custom filter, use the worksheet AddCustomFilter method which accepts the row index to which filter has to be applied and the custom filtering criteria.
The example below implements both auto- and custom data filters. In the example, the auto-filter feature is enabled and filtered rows are searched based on some criteria.
Input: the data list in the first worksheet
Output: enable auto-filter feature
Auto-filter
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Access active worksheet | |
var sheet = GridWeb1.WorkSheets[this.GridWeb1.ActiveSheetIndex]; | |
// Enable GridWeb's auto-filter. | |
sheet.AddAutoFilter(0, 0, sheet.Cells.MaxDataColumn); | |
sheet.RefreshFilter(); |
Custom Data Filter
Custom filtered data based on the criteria
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// Access active worksheet | |
var sheet = GridWeb1.WorkSheets[this.GridWeb1.ActiveSheetIndex]; | |
// Enable GridWeb's custom-filter. | |
sheet.AddCustomFilter(1, "CELL0=\"1\""); | |
sheet.RefreshFilter(); |