0

One can reproduce the problem.

  1. Create new Spreadsheet.

  2. Take SpreadsheetId (https://docs.google.com/spreadsheets/d/1rp11nqj0t0x1111111111111111111111111137Wj4XU/edit#gid=0, here it is 1rp11nqj0t0x1111111111111111111111111137Wj4XU)

  3. Fill range A1:F15 with any content, let's use 'lorem ipsum' string, for instance.

  4. Visit https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/batchUpdate 4.1 Look at right side where one can find "Try this method" 4.2 Fill field "spreadsheetId" with one you've taken on step 2. 4.3 Fill "Request body" with

    { "requests": [ { "repeatCell": { "cell": { "userEnteredFormat": { "textFormat": { "strikethrough": true } } }, "fields": "*", "range": { "startRowIndex": 2, "endRowIndex": 2, "startColumnIndex": 1, "endColumnIndex": 3 } } } ] }

4.4 Press "Execute" button at the bottom of right side. 5. Check you spreadshet. 6. No error, nothing happened.

What am I doing wrong ?

1 Answer 1

0

Modification points:

  • In your following request body, the values of startRowIndex and endRowIndex are the same. By this, this request body cannot be correctly worked. I thought that this might be the reason for your current issue of No error, nothing happened..

    {
       "requests":[
          {
             "repeatCell":{
                "cell":{
                   "userEnteredFormat":{
                      "textFormat":{
                         "strikethrough":true
                      }
                   }
                },
                "fields":"*",
                "range":{
                   "startRowIndex":2,
                   "endRowIndex":2,
                   "startColumnIndex":1,
                   "endColumnIndex":3
                }
             }
          }
       ]
    }
    
  • And also, in your request body, even when the above modification is reflected, the cell values are cleared by "fields":"*". Please be careful about this.

When these points are reflected in your request body, how about the following modification?

Modified request body:

{
  "requests": [
    {
      "repeatCell": {
        "cell": {
          "userEnteredFormat": {
            "textFormat": {
              "strikethrough": true
            }
          }
        },
        "fields": "userEnteredFormat.textFormat.strikethrough",
        "range": {
          "startRowIndex": 0,
          "endRowIndex": 15,
          "startColumnIndex": 0,
          "endColumnIndex": 6,
        }
      }
    }
  ]
}
  • In this modified request body, from Fill range A1:F15 with any content, let's use 'lorem ipsum' string, for instance., the cells "A1:F15" are used. So, strikethrough is used for these cells.

  • In your request body, sheetId is not used. So, in this case, the 1st tab in Google Spreadsheet is used. Please be careful about this. If you want to use it for the specific sheet, please add the property of "sheetId": ### to range. ### is the sheet ID.

References:

Sign up to request clarification or add additional context in comments.

1 Comment

values of startRowIndex and endRowIndex are the same === I tried your gift and It worked but it stroke through all cells in range A1:F15. Then I edited it to "startRowIndex": 1, "endRowIndex": 2, "startColumnIndex": 1, "endColumnIndex": 3 and it stroke through two cells in second row. "fields":"*" erases content of those two cells. It is unexpected behaviour. Thank you Tanaike, you helped me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.