Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python能否从pivot表字段中选择一个值,并且该pivot表是否来自现有连接_Python_Excel_Automation - Fatal编程技术网

Python能否从pivot表字段中选择一个值,并且该pivot表是否来自现有连接

Python能否从pivot表字段中选择一个值,并且该pivot表是否来自现有连接,python,excel,automation,Python,Excel,Automation,我使用xlwings在Python中控制excel,excel工作表有一个透视表字段。该数据透视表字段来自现有连接 目前显示为2020年10月28日,我可以从下拉框中手动将其更改为2020年10月29日。问题是如何使用python将其从2020年10月28日更改为2020年10月29日 有什么建议吗?任何其他python库都可以用于此工作?我使用此脚本修改透视表 我在excel中创建了一个宏,并用python复制了代码 sheet = "your_sheet" pivotT

我使用xlwings在Python中控制excel,excel工作表有一个透视表字段。该数据透视表字段来自现有连接

目前显示为2020年10月28日,我可以从下拉框中手动将其更改为2020年10月29日。问题是如何使用python将其从2020年10月28日更改为2020年10月29日


有什么建议吗?任何其他python库都可以用于此工作?

我使用此脚本修改透视表 我在excel中创建了一个宏,并用python复制了代码

sheet = "your_sheet"
pivotTableName = "pivot_table_name"
data = "your_field"
value = "10/29/2020"

sht = Wb.sheets[sheet].select()

pivotTable = Wb.api.ActiveSheet.PivotTables(pivotTableName)
filter_ = pivotTable.PivotFields(data)
filter_.CurrentPage = "(All)"
for f in filter_.PivotItems():
    f.Visible = f.Name == value
代码是在RPA Rocketbot上运行的,但是您可以通过检查模块存储库了解情况

我也依赖微软的文档

sheet = "your_sheet"
pivotTableName = "pivot_table_name"
data = "your_field"
value = "10/29/2020"

sht = Wb.sheets[sheet].select()

pivotTable = Wb.api.ActiveSheet.PivotTables(pivotTableName)
filter_ = pivotTable.PivotFields(data)
filter_.CurrentPage = "(All)"
for f in filter_.PivotItems():
    f.Visible = f.Name == value