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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With