Python - How to turn-on Excel Auto Filter on cells in non-first row?

ぐ巨炮叔叔 提交于 2019-12-31 05:11:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!