is there any way to add more than 1 autofilter to a worksheet ?
Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for considering Aspose.
Yes, you can add more than one autofilter on a worksheet, please see the sample code below.
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Opening the Excel file
//Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.Worksheets;
//Creating AutoFilter by giving the cells range of the heading row
worksheet.AutoFilter.Range = "A1:B1";
//Saving the modified Excel file in default (that is Excel 2003) format
Also, please see the following document link regarding the Data Filtering and Validation
Thank You & Best Regards,
So, after the document gets generated i’ve to reopen it toset the second autofilter ?
Well, Nausherwan's code simply adds an autofilter in the worksheet. But, I think you need to add more than 1 auto-filtering areas in a single worksheet, it not it? Well, MS Excel does not allow this feasibility. It allows only one auto-filter for a worksheet and you cannot add more than 1 auto-filtering source areas in a single sheet. We follows MS Excel standards, so, it is not possible.
Alternatively, you may utilize and try to implement Lists for you need (if it suits your requirements). Aspose.Cells supports to add Lists, please check the following documentation topic for your reference:
it seems that the listobject wont work on xlsx format ?
Yes, I 'm afraid the List objects are not supported in xlsx file formats yet. You have to use xls file format (MS Excel 97-2003) currently for you need. However, we will support the feature in our future versions.
Please try the attached version, we have supported to read/write the Excel 2007 Tables (List Objects) and Table styles in Xlsx file formats.