Read values from named ranges with openpyxl

醉酒当歌 提交于 2019-11-27 16:46:53

问题


How can I read values from named ranges in Excel with openpyxl?

I've found the sourcecode at http://openpyxl.readthedocs.org/en/latest/_modules/openpyxl/workbook/names/named_range.html but I can't figure out how to use it properly.


回答1:


wb = openpyxl.load_workbook(excel_file_name) 
rng = wb.get_named_range(name_of_range).destinations[0]
sheet = rng[0]
address = rng[1].replace('$','')
val = sheet[address].value


来源:https://stackoverflow.com/questions/28896209/read-values-from-named-ranges-with-openpyxl

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