Clear google sheet before adding new rows

Personally I prefer to delete all rows and unused columns from the sheet.

After adding a new sheet to your workbook, there will be a thousand rows.

Here’s the batchUpdate endpoint you can call using the “Make an API call” module, that will delete everything except the first row:

(module [5] is my “Add a Sheet” module)

POSTspreadsheets/{{5.spreadsheetId}}:batchUpdate

{
  "requests": [
    {
      "deleteDimension": {
        "range": {
          "sheetId": {{5.replies[].addSheet.properties.sheetId}},
          "dimension": "ROWS",
          "startIndex": 1,
          "endIndex": {{5.replies[].addSheet.properties.gridProperties.rowCount}}
        }
      }
    },
    {
      "deleteDimension": {
        "range": {
          "sheetId": {{5.replies[].addSheet.properties.sheetId}},
          "dimension": "COLUMNS",
          "startIndex": 4,
          "endIndex": {{5.replies[].addSheet.properties.gridProperties.columnCount}}
        }
      }
    }
  ]
}

2 Likes