Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Introducedin
8.3

...

8.3
Description

Excerpt

The AutoFilter class represents the filter that is applied to a selected area of cells in a worksheet.

Signature
C#
C#
public sealed class AutoFilter

{signature}

{signature:
}
Signature
vb.net
vb.net
Public NotInheritable Class AutoFilter

{signature}

{remarks}
To return an {{AutoFilter}} object, use [
Remarks

To return an AutoFilter object, use Worksheet.AutoFilter

|Worksheet.AutoFilter]. There is only one auto filter per worksheet; by default, the filter is not set and [AutoFilter.Area] will return {{null}}. When applying an auto filter to a select area of cells on a worksheet, bear in mind: # [AutoFilter.Area] must be set to an [Area] object on the same worksheet as the auto filter. # There is only one auto filter per worksheet. If [AutoFilter.Area] is already set, changing {{AutoFilter.Area}} will overwrite the previous area and the auto filter will be applied to the new area. # {{AutoFilter.Area}} must include all of the cells that the filter applies to. ExcelWriter will not automatically detect the boundaries of the filtered area. The filter will be removed from the worksheet either by calling the filter's [Clear()|AutoFilter.Clear()] method, by setting the {{Area}} property to {{null}}, or by deleting all the rows (or just the first row that has the filter headers) or all the columns of the filter from the worksheet. {remarks} {example} {code:csharp|title=C#}

.

There is only one auto filter per worksheet; by default, the filter is not set and AutoFilter.Area will return null.

When applying an auto filter to a select area of cells on a worksheet, bear in mind:

  1. AutoFilter.Area must be set to an Area object on the same worksheet as the auto filter.
  2. There is only one auto filter per worksheet. If AutoFilter.Area is already set, changing AutoFilter.Area will overwrite the previous area and the auto filter will be applied to the new area.
  3. AutoFilter.Area must include all of the cells that the filter applies to. ExcelWriter will not automatically detect the boundaries of the filtered area.

The filter will be removed from the worksheet either by calling the filter's Clear() method, by setting the Area property to null, or by deleting all the rows (or just the first row that has the filter headers) or all the columns of the filter from the worksheet.

Example
Code Block
csharp
csharp
titleC#


ExcelApplication xla = new ExcelApplication();
Workbook wb = xla.Create(ExcelApplication.FileFormat.Xlsx);
AutoFilter autoFilter = wb.Worksheets[0].AutoFilter;
{code} {code:vbnet|title=
Code Block
vbnet
vbnet
titlevb.net
}


Dim xla As New ExcelApplication()
Dim wb As Workbook = xla.Create(ExcelApplication.FileFormat.Xlsx)
Dim autoFilter As AutoFilter = wb.Worksheets(0).AutoFilter
{code} {example} {exceptions} {exception:ArgumentException} An exception of type {{ArgumentException}} will be thrown if the {{AutoFilter.Area}} property is set to an area that is on a different worksheet, or an empty area that doesn't have any data in it. {exception} {properties} || Name || Description || | [Area|AutoFilter.Area] | {excerpt-include:AutoFilter.Area|nopanel=true} | {methods} || Name || Description || | [Clear()|AutoFilter.Clear()] | {excerpt-include:AutoFilter.Clear()|nopanel=true} |
Exceptions
Exception
ArgumentException
ArgumentException

An exception of type ArgumentException will be thrown if the AutoFilter.Area property is set to an area that is on a different worksheet, or an empty area that doesn't have any data in it.

Properties

Name

Description

Area

Excerpt Include
AutoFilter.Area
AutoFilter.Area
nopaneltrue
Methods

Name

Description

Clear()

Excerpt Include
AutoFilter.Clear()
AutoFilter.Clear()
nopaneltrue