We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem with Autofilter

Hello,
is there any way to add more than 1 autofilter to a worksheet ?

cu,
Lankabel

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.

SampleCode:

//Instantiating a Workbook object

Workbook workbook = new Workbook();

//Opening the Excel file

workbook.Open("C:\\output.xls");

//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 in default (that is Excel 2003) format

workbook.Save("C:\\autoFilter.xls", FileFormatType.Default);

Also, please see the following document link regarding the Data Filtering and Validation

http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/data-filtering-and-validation.html

Thank You & Best Regards,

So, after the document gets generated i’ve to reopen it toset the second autofilter ?

Hi Lankabel,

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:

http://www.aspose.com/documentation/file-format-components/aspose.cells-for-.net-and-java/creating-a-list-object.html

Thank you.

Hello,
it seems that the listobject wont work on xlsx format ?

cu

Hi,

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.

Thank you.

Hi,

Please try the attached version, we have supported to read/write the Excel 2007 Tables (List Objects) and Table styles in Xlsx file formats.


Thank you.