简体   繁体   English

如何使用 xlwings 更改 pivot 表选项?

[英]How to change pivot table option using xlwings?

When I make the pivot table in Excel, I usually use pivot table option and change to 'Classic Pivot table layout'当我在 Excel 中制作 pivot 表格时,我通常使用 pivot 表格选项并更改为“经典 Pivot 表格布局”

I want to do it by using xlwings我想用 xlwings 来做

Would you give me any suggetions?你能给我什么建议吗?

Thank you.谢谢你。

I tried to find it but I couldn't find it我试图找到它,但找不到

By recording a macro of selecting 'Classic PivotTable layout' in the Display tab of PivotTable Options, is returned the following:通过在数据透视表选项的显示选项卡中记录选择“经典数据透视表布局”的宏,返回以下内容:

Range("G8").Select
ActiveSheet.PivotTables("PivotTable1").InGridDropZones = True

To set this via xlwings you can call the .api in the worksheet with (this does select the tickbox in the options):要通过 xlwings 设置它,您可以调用工作表中的.api (这会在选项中的复选框中调用 select):

ws = wb.sheets("Sheet1")
ws.api.PivotTables("PivotTable1").InGridDropZones = True

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM