Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear filters in Excel using xlwings?

My team are xlwings in Sypder (Python) to convert Excel tables into CSV format. When a table is filtered however, this alters the CSV output. Is there an xlwings command which can clear the filter from the active Excel sheet?

A similar command in VBA would be (from Excel 2013 VBA Clear All Filters macro):

Sub Macro1()
    Cells.AutoFilter
End Sub
like image 608
Finger Picking Good Avatar asked Oct 19 '25 02:10

Finger Picking Good


1 Answers

wb.sheets[sheetname].api.AutoFilterMode = False Will remove the filter from the sheet, if you want to just clear the filter showing all the data without removing it you can use: wb.sheets[sheetname].api.AutoFilter.ShowAllData()

like image 119
avkch Avatar answered Oct 21 '25 16:10

avkch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!