Overview
This article teaches how to delete all rows in a Google Sheets spreadsheet using Workflows.
Solution
All the rows need to be deleted in the following spreadsheet except the headers:
Google Sheets spreadsheet.
This flow deletes a range of rows from a Google Sheets spreadsheet using the Google Sheets API:
Workflows flow to delete all spreadsheet rows.
JSON request indicating the rows to clear:
{
"requests": [
{
"deleteDimension": {
"range": {
"sheetId": 0,
"dimension": "ROWS",
"startIndex": 1,
"endIndex": 11
}
}
}
]
}
Running the flow will clear all the spreadsheet rows:
How the flow works
- The Flow Control-Assign card sets the Google Sheets spreadsheet ID.
- The Text-Compose card builds the API URL:
/v4/spreadsheets/{Spreadsheet ID}:batchUpdate. It uses the Spreadsheet ID from the Assign card. - The second Text-Compose card builds the JSON request body. It uses the
deleteDimensionrequest to delete rows 2–11 (startIndex: 1, endIndex: 11) from the first sheet (sheetId: 0). UpdatestartIndexandendIndexto match the rows you want to delete. - The Google Sheets-Custom API Action card makes a POST request to the Google Sheets spreadsheets.batchUpdate API.
Spreadsheet after running the flow.
Related References
- Export Google Sheets Data to a Workflows Table
- Save User MFA Information to a Google Sheets Spreadsheet in Workflows
