300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > python写下拉列表在excel 无法使用python获取Excel下拉列表(组合框)值

python写下拉列表在excel 无法使用python获取Excel下拉列表(组合框)值

时间:2018-07-14 22:37:50

相关推荐

python写下拉列表在excel 无法使用python获取Excel下拉列表(组合框)值

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.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。