これは簡単な作業ですが、私の人生では解決策を見つけることができません。私はテーブルを持つ優れた文書を持っています。この表の列には、すべてオートフィルタが適用されています。私がしたいのは、そのオートフィルター(9番目の列)のすべての項目を選択して配列に格納できることだけです。私はWin32Comを使用しています。Python - Excel AutoFilterで選択項目を表示する方法
import win32com.client as win32
working_dir = 'C:\\invoice\\'
save_dir = 'C:\\test\\'
xl = win32.gencache.EnsureDispatch("Excel.Application")
xl.Visible = True
template_wb = xl.Workbooks.Open(working_dir + 'Settlement report V6-EMPLATE.xlsm')
#Worksheets
orgdata_ws = template_wb.Sheets('Organization Data')
masterdata_ws = template_wb.Sheets('Master Data')
#I want to access the autofilter in column 9 and simply get the contents in the autofilter list and put them in the array
filtercontents = []
thefilter = orgdata_ws.Columns(9).Autofilter
for i in thefilter:
filtercontents.append(i) ?????????
例外はありますか? –
Raphaelこんにちは、この特定のコードで、私はこのエラーが表示されます: TypeError: 'instancemethod'オブジェクトはiterableではありません。 しかし、目標を達成するために正しい方法を使用していない可能性が高いです。また、私は自動フィルタをAutoFilterに変更しました:) –