无法使用python获取Excel下拉列表(组合框)值 [英] Can't get Excel drop-down list (combobox) value with python
问题描述
我有一个带下拉列表的excel文件,我想从python访问其当前值。
在vba中,代码非常简单:
Sheets( name_of_my_sheet)。name_of_my_list.value
我在xlrd中寻找了一个等价物,但找不到。
我得到了答案。下拉框列表是在运行时在vba中创建的,因此您无法从xls中读取其值。
解决方案是用VBA编写更改方法,该方法实际上会将值写入框下面的单元格。
Sub My_List_Change()
工作表(包含您的盒子)。Cells(x,y)= My_List.value // x,y是由盒子
然后,每次保存表格并想从python中读取它时,您都可以访问当前值。
I have an excel file with a drop-down list and I would like to access its current value from python.
In vba the code is really simple :
Sheets("name_of_my_sheet").name_of_my_list.value
I looked for an equivalent in xlrd but couldn't find one.
I got my answer. The list the drop-down box is created at run time in vba so you can't "read" its value from the xls.
The solution is to write in VBA an on change method that will actually write the value to the cell under the box.
Sub My_List_Change()
Sheets("Containing your box").Cells(x,y) = My_List.value // x,y being the coordinates of the cell hidden by the box
Then each time you save your sheet and want to read it from python you can access the current value.
这篇关于无法使用python获取Excel下拉列表(组合框)值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!