I’m trying to combine cells in my Google Sheets document using the Python API but it’s not working. I can create new sheets and add data to them just fine, but when I try to merge cells for my header section, nothing happens.
header_merge_config = [
{'mergeCells': {
'mergeType': 'MERGE_COLUMNS',
'range': {
'endColumnIndex': 4,
'endRowIndex': 1,
'sheetId': '998877665',
'startColumnIndex': 0,
'startRowIndex': 0
}
}},
{'mergeCells': {
'mergeType': 'MERGE_COLUMNS',
'range': {
'endColumnIndex': 7,
'endRowIndex': 1,
'sheetId': '998877665',
'startColumnIndex': 4,
'startRowIndex': 0
}
}}
]
sheets_service.spreadsheets().batchUpdate(
spreadsheetId=my_spreadsheet_id,
body={'requests': header_merge_config}
).execute()
The code runs without any errors and I get an empty response back, but the cells don’t actually merge in the spreadsheet. What am I doing wrong here?