簡體   English   中英

如何使用 win32com.client 在數據透視表中按日期字段分組

[英]How to Group by Date Field in a PivotTable using win32com.client

我從過去幾個小時嘗試了很多方法,但沒有運氣。 有人請幫助我。

group_dt = pt.PivotFields('Created')
group_dt.LabelRange.Group(Start=True, End=True, Periods=Array(False, False, False, False, True, False, True))

錯誤:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-75-0355ab1abb88> in <module>
      1 group_dt = pt.PivotFields('Created')
----> 2 group_dt.LabelRange.Group(Start=True, End=True, Periods=Array(False, False, False, False, True, False, True))

TypeError: 'str' object is not callable

經過大量研究,我找到了使用 win32com.client 對日期字段進行分組的方法

cell = pivot_sheet.Range('B5')
cell.Group(Start=True, End=True, Periods=list([False, False, False, False, True, False, True]))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM