Hi, I am using Python 2.6 + xlwt module to generate excel files.
Is it possible to include an autofilter in the first row with xlwt or pyExcelerator or anything else besides COM?
Thanks
Hi, I am using Python 2.6 + xlwt module to generate excel files.
Is it possible to include an autofilter in the first row with xlwt or pyExcelerator or anything else besides COM?
Thanks
I found this message in a Google group. It looks like it's not possible, unfortunately.
AFAIK xlwt doesn't allow you to add an "autofilter".
But you can add an "autofilter" using Mark Hammond's Python Win32 Extensions. Download for 2.6 here.
Something like this should work (tested in Python 2.5.4):
>>> from win32com.client import Dispatch
>>> xl = Dispatch("Excel.Application")
>>> xl.Workbooks.Open("c:/full/path/to/your/excel_file.xls")
>>> xl.ActiveWorkbook.ActiveSheet.Columns(1).AutoFilter(1)
>>> xl.ActiveWorkbook.Close(SaveChanges=1) # 1 is True, 0 is False
>>> xl.Quit()