Worksheet: unmerge_cells() raises KeyError when unmerged cell does not exist in self._cells
When unmerging cells from a worksheet with worksheet.unmerge_cells()
, in some cases a KeyError
ist raised, because not all merged cells are contained in _cells
after e.g. a row has been deleteted from the worksheet with delete_rows()
The reason is, that if e.g. a row is deleted, which contained merged cells, the merged_cells.ranges
are not updated correctly.
problem:
def unmerge_cells(self, range_string=None, start_row=None, start_column=None, end_row=None, end_column=None):
[...]
for row, col in cells:
del self._cells[(row, col)]
--> KeyError
raised by _cells[(row, col)]
Edited by Norbert Nikolaus