Skip to main content

IXlTable.HasAutoFilter Property

Gets or sets a value indicating whether the filtering functionality is enabled for the table.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v24.2.Core.dll

Declaration

bool HasAutoFilter { get; set; }

Property Value

Type Description
Boolean

true, to enable filtering for the table; otherwise, false.

Remarks

By default, the HasAutoFilter property is true and filtering is enabled for a table. The following image demonstrates a table with the filtering functionality turned on (the workbook is opened in Microsoft® Excel®).

SpreadsheetDocServer_EnabledAutoFilter

Drop-down arrows are displayed on the right side of each column header in the table. An end-user can click the arrow of the desired column and select the required filter options from the drop-down menu.

To disable filtering for a table, and thereby prevent end-users from filtering and sorting table data, set the HasAutoFilter property to false, as shown in the example below.

Note

A complete sample project is available at https://github.com/DevExpress-Examples/excel-export-api-examples

IXlTable table;
// Specify an array containing column headings for a table.
string[] columnNames = new string[] { "Product", "Category", "Amount" };

// Create the first row in the worksheet from which the table starts.
using (IXlRow row = sheet.CreateRow())
{
    // Start generating the table with a header row displayed.
    table = row.BeginTable(columnNames, true);
    // Disable the filtering functionality for the table. 
    table.HasAutoFilter = false;
    // Specify the total row label.
    table.Columns[0].TotalRowLabel = "Total";
    // Specify the function to calculate the total.
    table.Columns[2].TotalRowFunction = XlTotalRowFunction.Sum;
}

// Generate table rows and populate them with data.
using (IXlRow row = sheet.CreateRow())
    row.BulkCells(new object[] { "Camembert Pierrot", "Dairy Products", 17000 }, null);
using (IXlRow row = sheet.CreateRow())
    row.BulkCells(new object[] { "Gnocchi di nonna Alice", "Grains/Cereals", 15500 }, null);
using (IXlRow row = sheet.CreateRow())
    row.BulkCells(new object[] { "Mascarpone Fabioli", "Dairy Products", 15000 }, null);
using (IXlRow row = sheet.CreateRow())
    row.BulkCells(new object[] { "Ravioli Angelo", "Grains/Cereals", 12500 }, null);

// Create the total row and finish the table.
using (IXlRow row = sheet.CreateRow())
    row.EndTable(table, true);
See Also