Python Clearing Excel AutofilterPython

Python-Programme
Guest
 Python Clearing Excel Autofilter

Post by Guest »

Ich automatisiere derzeit einen Prozess mit Python und Xlwings und muss alle Autofilter in einem Arbeitsblatt für Ziele Excel löschen. Ich habe zahlreiche Proben gesehen, die sich mit < /p>
beziehen

Code: Select all

if wb.sheets[sheetname].api.AutoFilterMode:
wb.sheets[sheetname].api.AutoFilter.ShowAllData()
< /code>
Aber wenn ich dies versuche Der Blattname usw. ist korrekt, da andere Code (nicht gezeigt) gut funktioniert. < /p>
import xlwings as xw

# Open the target workbook
wb = xw.Book('SOP_DL_AutofilterTest.xlsx')
ws = wb.sheets['SOP DL']

if wb.sheets['SOP DL'].api.AutoFilterMode:
wb.sheets['SOP DL'].api.AutoFilter.ShowAllData()

# Keep the window open
input("Press Enter to exit...")  # This will keep the browser open until you press Enter

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post