Reading Table Objects
Hi,
This is either a documentation issue or a feature request. Currently openpyxl has no problem finding named tables and exposing the resulting column names ("headers") using an array of tableColumns
objects. However, I can't seem to find any documentation describing how to iterate over the rows within that column and extract the values.
Here's an example. Consider the excel table below.
a | b | c |
---|---|---|
1 | 3 | 5 |
2 | 4 | 6 |
Ideally I could transform this table into an array of dicts 'dict_array` with values shown below.
dict_arr[0]['b'] = 3
dict_arr[0]['c'] = 5
dict_arr[1]['a'] = 2
dict_arr[2]['b'] = 4
dict_arr[3]['c'] = 6
This can currently be done by parsing the table range, extracting the first row as keys in the dict and then iterating across the remaining sheet rows for the values. Is there an easier way that I'm missing?