使用openpyxl从命名范围读取值 [英] Read values from named ranges with openpyxl

查看:139
本文介绍了使用openpyxl从命名范围读取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用openpyxl从Excel的命名范围中读取值?

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

我在 http:/上找到了源代码/openpyxl.readthedocs.org/en/latest/_modules/openpyxl/workbook/names/named_range.html ,但我不知道如何正确使用它.

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.

推荐答案

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

这篇关于使用openpyxl从命名范围读取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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