We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to clear autofilters

Thread ID:

Created:

Updated:

Platform:

Replies:

84407 Jun 30,2009 04:24 PM UTC Aug 7,2019 02:08 PM UTC WinForms 5
loading
Tags: XlsIO
Wout de Zeeuw
Asked On June 30, 2009 04:24 PM UTC

Hi,

I'm trying to clear autofilters, but can't figure out how to do it. Is there any example code somewhere? IWorksheet.AutoFilters.FilterRange seems to be close, but how to set it to an empty range? I can't set it to null.

Thanks!

Wout

Geetha M [Syncfusion]
Replied On July 1, 2009 11:48 AM UTC

Hi Wout,

Thank you for your continued interest in Syncfusion products.

Currently it is not possible to clear filters. But you can workaround this by changing the current FilterRange. You can check the code snippet below.

sheet.AutoFilters.FilterRange = sheet[30,20];

Please try this and let me know if you have any questions.

Regards,
Geetha

Wout de Zeeuw
Replied On July 1, 2009 03:36 PM UTC

Hi,

I tried this workaround, which works ok luckily:

CType(newWorkSheet.AutoFilters, Syncfusion.XlsIO.Implementation.Collections.AutoFiltersCollection).Clear()

If the AutoFilters (IAutoFilters) interface could expose the Clear() method, then the ugly cast wouldn't be needed.

Best regards,

Wout

Geetha M [Syncfusion]
Replied On July 2, 2009 06:21 AM UTC

Hi Wout,

Thank you for the details.

I have logged a feature request on this regard and will get back to you once it is implemented.

Regards,
Geetha

Paul Meems
Replied On August 6, 2019 10:24 AM UTC

I know this is an old question but is the suggested answer still the best solution:
((Syncfusion.XlsIO.Implementation.Collections.AutoFiltersCollection) worksheet.AutoFilters).Clear();

I need to remove the filters before saving my workbook under a different name (SaveAs) because the rows that are filtered out don't make it to the new workbook.

Abirami Varadharajan [Syncfusion]
Replied On August 7, 2019 02:08 PM UTC

Hi Paul, 
 
You can unhide the filtered out rows after clearing the autofilters using ShowRange of IWorksheet . Please refer to below code to achieve the same. 
 
Code Example: 
                  (worksheet.AutoFilters as AutoFiltersCollection).Clear(); 
                  worksheet.ShowRange(worksheet.UsedRange, true); 
 
Please refer to below documentation to know more on show or hide specific range. 
 
 
Kindly try this and let us know if this meets your requirement. 
 
Regards, 
Abirami 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;