How the Aspose Cells control implements data filtering (with code and download address)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.