In theory this was answered in Remove only formatting on a cell range selection with google spreadsheet API but for the life of me I cannot get it to work.
I want to write a function that clears the formatting of a given Google Sheet. Here is what I think is the right way to do it based on the above:
def clear_sheet_formatting():
spreadsheetID = "1pQoBG0q6f0Ni6yMiC9BSIXVLGMmvBRc07pGXqMA2VtA"
global service_spreadsheets
open_connection()
body = {
"requests": [
{
"updateCells": {
"range": {
"sheetId": "Sheet1",
},
"fields": "userEnteredFormat"
}
}
]
}
func = lambda: service_spreadsheets.batchUpdate(spreadsheetId=spreadsheetID,
body=body).execute()
result = execute_query(func)
The sheet itself is very boring:
But I am getting the following error:
WARNING:root:Google API call failed with the following error, sleeping 20 seconds: Invalid value at 'requests[0].update_cells.range.sheet_id' (TYPE_INT32), "Sheet1"
What am I doing wrong? How do I make this work?