是否可以通过Python(pywin32)访问Excel上的Slicers [英] Is there a way to access Slicers on Excel via Python (pywin32)

查看:297
本文介绍了是否可以通过Python(pywin32)访问Excel上的Slicers的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用pywin32(Excel的工作簿).我在工作表中有一些必须保存的图表.事实是,此工作表中有一个切片器,可以对某个变量进行过滤.我没有找到pywin32文档,而且我对如何(或无法)做到这一点没有任何了解. 谢谢

I am working with pywin32, workbooks for Excel. I have some charts in a sheet that i have to save. The thing is that there's a slicer in this sheet that permit to filter on a certain variable. I didn't find pywin32 docs for it and i do not have any clue here on how i can (or can't) do it.. Thanks

推荐答案

在Excel中,显然其中有一个程序可以记录您单击的所有内容,因此,如果要操作过滤器/切片器,可以右键单击该元素,然后选择分配宏".然后,您可以单击离开,因为它记录了您的点击.完成操作后,您可以通过再次选择分配宏"来查看它.然后会出现一个弹出窗口,您可以选择your_filter/slicer_name_Click,它将为您提供VBA代码.您所要做的就是更改它,使其适合python格式,或者您可以像 .

Apparently in Excel, there is a program within it that could record anything you click so if you want to manipulate the filter/slicer, you can right click the element, and then choose "Assign Macro". Then you can click away as it records your clicks. Once youre done, you can view it by again choosing "Assign Macro" and a pop-up window will be available and you can choose your_filter/slicer_name_Click and it will provid you the VBA code. All you have to do is change it so it fits python format or you can implement it like this.

这篇关于是否可以通过Python(pywin32)访问Excel上的Slicers的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆