问题
I'm trying to turn-on Auto-Filter in Excel for some cells at row 5, preferably using Python Win32.
For example:
from win32com.client import Dispatch
xl = Dispatch("Excel.Application")
xl.Workbooks.Open(<file name>)
xl.ActiveWorkbook.ActiveSheet.Range('A5:D5').AutoFilter()
xl.ActiveWorkbook.Close(SaveChanges=1)
del(xl)
It still creates Auto Filter in the first row. Update: It works correctly, see comments.
I know that it is possible to set AutoFilter using ActiveSheet.Columns
property, but it implies first row?
I'm using Windows XP, with Excel 2002 installed.
来源:https://stackoverflow.com/questions/11957420/python-how-to-turn-on-excel-auto-filter-on-cells-in-non-first-row