diff --git a/gspread/worksheet.py b/gspread/worksheet.py index 1c89b5ec1..3d895b021 100644 --- a/gspread/worksheet.py +++ b/gspread/worksheet.py @@ -2728,6 +2728,23 @@ def merge_cells(self, name: str, merge_type: str = MergeType.merge_all) -> Any: return self.client.batch_update(self.spreadsheet_id, body) + def batch_merge( + self, + merges: List[Dict[Literal["range", "mergeType"], Union[str | MergeType]]], + merge_type: MergeType = MergeType.all, + ) -> Any: + requests = [ + { + "merges": { + "range": a1_range_to_grid_range(i["range"], self.id), + "mergeType": i.get("mergeType", merge_type), + } + } + for i in merges + ] + + return self.client.batch_update(self.spreadsheet_id, {"requests": requests}) + @cast_to_a1_notation def unmerge_cells(self, name: str) -> JSONResponse: """Unmerge cells.