Can't get Excel drop-down list (combobox) value with python

不想你离开。 提交于 2019-12-06 14:52:52

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/6935529/cant-get-excel-drop-down-list-combobox-value-with-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!