Reputation: 51
I'm trying to read merged cells from sheet and unfortunately nothing is working for me. I'm in a situation where i want to read Row merges, column merges or may be combination of both. Any help will be appreciated. PS. I already tried sheets.merged_cells which returns blank array.
Thank you.
Upvotes: 4
Views: 7894
Reputation: 1
If formatting_info=True doesn't work you can use
merged_cells_decoded = []
for l in sheet.merged_cells:
x,x1,y,y1 = l[0],l[1]-1,l[2],l[3]-1
merged_cells_decoded += [(x,y,x1,y1)]
#sheet.merge_range(0,0,0,1,'№', header_style) 0,1,0,2 (merged_cells value) -> [(0, 0, 0, 1)]
#sheet.merge_range(0,3,0,5,'test', header_style) 0,1,3,6 (merged_cells value) -> [(0, 3, 0, 5)]
Upvotes: 0
Reputation: 82942
Docs: http://xlrd.readthedocs.io/en/latest/api.html#xlrd.sheet.Sheet.merged_cells
Please ensure that you have read the second "Note" -- if you don't specify formatting_info=True
in xlrd.open_workbook()
, you will get an empty list (what you call a "blank array").
Upvotes: 6