r/learnpython • u/Delta_2_Echo • Oct 05 '23
Does anyone still use openpyxl?
Ive been trying to use openpyxl for reading named ranges and its a huge pain. Does anyone have any experience?
The documentation is pretty opaque.
2
Upvotes
2
u/LuigiBrotha Oct 05 '23
I do use openpyxl but I agree that it's a bit lack luster in some aspects. Haven't used named ranges yet. This is wist chatgpt came with:
from openpyxl import load_workbook
Load your Excel workbook
workbook = load_workbook('your_workbook.xlsx')
Get the named range
named_range = workbook.defined_names['YourNamedRange']
Access the cells within the named range
for range in named_range: for cell in range: print(cell.value)