def _clean_merge_range(self, cr): """ Remove all but the top left-cell from a range of merged cells and recreate the lost border information. Borders are then applied """ mcr = MergedCellRange(self, cr.coord) cells = chain(mcr.rows) next(cells) # skip first cell try: for row, col in cells: self._cells[row, col] = MergedCell(self, row, col) except ValueError: for cell in cells: row, col = cell[0] self._cells[row, col] = MergedCell(self, row, col) mcr.format()
def _clean_merge_range(self, mcr): """ Remove all but the top left-cell from a range of merged cells and recreate the lost border information. Borders are then applied """ cells = mcr.cells next(cells) # skip first cell for row, col in cells: self._cells[row, col] = MergedCell(self, row, col) mcr.format()
def _clean_merge_range(self, cr): """ Remove all but the top left-cell from a range of merged cells and creates a MergedCellRange object to recreate the lost border information. After deletion of cells a reformat is issued. """ min_col, min_row, max_col, max_row = cr.bounds mcr = MergedCellRange(self, cr.coord) self._merged_cell_range.update({cr.bounds: mcr}) rows = range(min_row, max_row + 1) cols = range(min_col, max_col + 1) cells = product(rows, cols) for row, col in islice(cells, 1, None): self._cells[row, col] = MergedCell(self, row, col) mcr.format()