I have an excel spreadsheet with a named range. I am trying to extract each column of the named range as a list.
I have written a script so that Python can identify the cell range ( in this case, F4:H10), as shown.
I now want to assign a list for each column, i.e. Height = [100, 200, 400, 200, 300].
I tried following the method attached: Read Excel File in Python
However, I need to use defined ranges, as I move the spreadsheet around often, and can't afford to go through the python script each time I rearrange the excel sheet, and pandas wanted me to identify the column as the letter of the column the table is in.
file = 'foo.xlsx'
wb = openpyxl.load_workbook(file, data_only = True)
address = list(wb.defined_names['mytest'].destinations)
for sheetname, cellAddress in address:
cellAddress = cellAddress.replace('$', '')
print(cellAddress)