Reputation: 2853
I have a newly created xlsx workbook with one sheet. A1:A2 is merged and contains the string 'test'.
Using openpyxl (2.3.0) I can access the sheet and the cell value but worksheet.merged_cell_ranges
and worksheet.merged_cells
are both empty:
wb = workbook.worksheets[0] # ReadOnlyWorksheet: <ReadOnlyWorksheet "Sheet1">
wb.cell(row=1, column=1) # 'test'
wb.merged_cell_ranges # list: []
wb.merged_cells # set: set([])
The documentation (http://openpyxl.readthedocs.org/en/latest/api/openpyxl.worksheet.html) and answers to other SO questions indicate that this is not the expected behaviour.
Yes, the cells are definitely merged. Am I doing something wrong?
Upvotes: 4
Views: 8783
Reputation: 2853
The merged_cells
and merged_cell_ranges
properties are not populated when the workbook has been opened in read-only mode.
Prompted by Charlie Clark's comment, I opened the workbook without the read-only flag and the merged_cells
and merged_cell_ranges
properties were correctly populated.
Submitted bug #540.
Upvotes: 9