Turn off filter buttons for table listObject

How can I turn off the filter buttons that are applied to table listObjects that have headers?

@BRGQST

To turn off the filter buttons for a table ListObject that has headers in Aspose.Cells, you can use the ShowFilterButton property of the AutoFilter class. Here’s how you can do it:

  1. Load your workbook and access the desired ListObject.
  2. Set the ShowFilterButton property to false.

Here is a code example in C#:

// Load the workbook
Workbook workbook = new Workbook("YourWorkbook.xlsx");

// Access the first worksheet
Worksheet worksheet = workbook.Worksheets[0];

// Access the ListObject (table)
ListObject table = worksheet.ListObjects[0];

// Turn off the filter buttons
table.AutoFilter.ShowFilterButton = false;

// Save the workbook
workbook.Save("YourUpdatedWorkbook.xlsx");

This code will effectively remove the filter buttons from the specified ListObject in your Excel file. Make sure you are using a version of Aspose.Cells that supports this property, as it was introduced in a later version [1].

Sources:
[1]: ListObject AutoFilter Removal, Show/Hide flag

1 Like

I’m getting headers on my table even when the header bool is zero in this statement:

listObjects.Add(startRow, startCol, endRow, endCol, headers);

Disregard the above question. Thank you

@BRGQST
Thank you for your feedback. I hope your issue has been resolved by calling the following code. If you have any questions, please feel free to contact us at any time.

// Turn off the filter buttons
ListObject.AutoFilter.ShowFilterButton = false;