Skip to content

Instantly share code, notes, and snippets.

@empiricalthought
Created December 21, 2017 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save empiricalthought/3f0b3a501720b87d4a4c4f0b7e372e62 to your computer and use it in GitHub Desktop.
Save empiricalthought/3f0b3a501720b87d4a4c4f0b7e372e62 to your computer and use it in GitHub Desktop.
openpyxl named range
from openpyxl import load_workbook
workbook = load_workbook(filename='./tmp/book.xlsx', read_only=True)
range = workbook.defined_names['a_named_range']
for sheet_title, sheet_coords in range.destinations:
sheet = workbook[sheet_title]
for row in sheet[sheet_coords]:
print "\t".join(str(cell.value) for cell in row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment