How about this solution? In this solution, you problem can be solved by 2 times of API requests.
1. Retrieve all conditional formats from a sheet on Spreadsheet.
sheets.spreadsheets.get
is used for this situation.
Request :
GET https://sheets.googleapis.com/v4/spreadsheets/### spreadsheet ID ###?ranges=### sheet name ###&fields=sheets%2FconditionalFormats%2Franges%2FsheetId
Please input ### spreadsheet ID ###
and ### sheet name ###
.
Response :
This response retrieves the number of conditional formats. This is used for deleting conditional formats.
{"sheets": [{"conditionalFormats": [
{"ranges": [{"sheetId": #####}]},
{"ranges": [{"sheetId": #####}]}
]}]}
2. Delete all conditional formats.
sheets.spreadsheets.batchUpdate
is used for this situation.
Request :
POST https://sheets.googleapis.com/v4/spreadsheets/### spreadsheet ID ###:batchUpdate
Request body :
Here, index
means the number of conditional formats retrieved by above GET
method. For example, when there are 2 conditional formats in the sheet, the length of requests
is 2. The following requests[0]
means sheets.conditionalFormats[0]
as shown above.
{"requests": [
{"deleteConditionalFormatRule": {"sheetId": #####, "index": 0}},
{"deleteConditionalFormatRule": {"sheetId": #####, "index": 1}}
]}
Please input ### spreadsheet ID ###
and sheetId
.
Note :
- In order to use above APIs, you can retrieve access token.
- Because to delete all conditional formats on a sheet is the aim, the information which is retrieved from spreadsheet is the necessity minimum.
References :
If I misunderstand your question, I'm sorry.