Home > database >  Formatting Cells in Google Sheets using API
Formatting Cells in Google Sheets using API

Time:06-11

I have the following request body to change multiple cell colors to red. However only one cell is being updated to red. Any ideas?

{'requests': [{'updateCells': {'range': {'sheetId': 212797248,
 'startRowIndex': 1,
 'endRowIndex': 6,
 'startColumnIndex': 0,
 'endColumnIndex': 10},
'rows': [{'values': [{'userEnteredFormat': {'backgroundColor': {'red': 1}}}]}],
'fields': 'userEnteredFormat.backgroundColor'}}]}

CodePudding user response:

Try with

  {
    "requests": [
      {
        "repeatCell": {
          "range": {
            'sheetId': 1476957615, // 212797248,
            'startRowIndex': 1,
            'endRowIndex': 6,
            'startColumnIndex': 0,
            'endColumnIndex': 10
          },
          "cell": {
            "userEnteredFormat": {
              "backgroundColor": {
                "red": 1
              }
            }
          },
          "fields": "userEnteredFormat(backgroundColor,textFormat,horizontalAlignment)"
        }
      }
    ]
  }
  • Related