Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read values from named ranges with openpyxl

Tags:

openpyxl

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.

like image 504
Jamgreen Avatar asked Mar 06 '15 09:03

Jamgreen


1 Answers

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
like image 164
Chad Avatar answered Oct 24 '22 00:10

Chad