Aspose Cells is a class library that operates and processes and transforms Excel files, supported. NET and Java editions, almost all the features Excel can achieve, Aspose cells can be implemented, in Excel often use data filtering, filtering rules to achieve the desired results, general filtering is based on the conditions set, usually text, numbers or dates.
Aspose cells Control: http://www.componentcn.com/kongjianchanpin/yonghujiemian/biaogekongjian/2014-09-16/174.html
Let's start by introducing how the automatic data filtering function is implemented in Excel.
1. First click on a column header in the work table, then select Filter and Auto Filter in the Data menu.
2. Then click on the filter arrows to view the filter list options
Automatic filtering in aspose cells is also fairly straightforward, and the control provides the worksheet class, which contains various properties and methods, where the AutoFilter property is used for filtering, which is an instance object of the AutoFilter class. The Range property is provided to specify the scope of the table header cell, and only one filter range can be specified in each worksheet, which is limited by Excel and is not caused by the control. If the customer needs to set up the custom filter for the data can be set using Autofilter.custom.
The following example code illustrates how to use aspose cells for automatic filtering
Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream ("C:\\book1.xls", FileMode.Open);
Instantiating a Workbook object
Opening the Excel file through the file 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";
Saving the modified Excel file
Workbook. Save ("C:\\output.xls");
Closing the file stream to free all resources
FStream. Close ();
Similarly, developers can invoke the filter method of the AutoFilter class to set the filtering conditions
Creating AutoFilter by giving the cells range of the heading row
Worksheet. Autofilter.range = "A1:B1";
Filter a column with the specified value
Worksheet. Autofilter.filter (1, "Bananas");
How the Aspose Cells control implements data filtering (with code and)