如何请求多行的 updateCells 具有相同的值
How to request updateCells for multiple rows to have the same value
我正在使用此请求代码将这些复选框插入列中,但我还需要将它们全部默认设置为 true。到目前为止,我已经看到了多个 "values" 的例子,每行一个,但我想知道是否有一种方法可以只声明一次并且已经为范围
中的所有其他人设置
var resource = {"requests": [
{"repeatCell": {
"cell": {"dataValidation": {"condition":{"type": "BOOLEAN"}}},
"range": {"sheetId": sheetId, "startRowIndex": 1, "endRowIndex": 300, "startColumnIndex": 18},
"fields": "dataValidation"
}
},
{"updateCells": {
"rows": {"values": {"userEnteredValue": {"boolValue": true}}},
"range": {"sheetId": sheetId, "startRowIndex": 1, "endRowIndex": 300, "startColumnIndex": 18},
"fields": "userEnteredValue"
}
}
]};
Sheets.Spreadsheets.batchUpdate(resource, ss.getId());
与其同时使用 repeatCell
和 updateCells
请求,不如使用单个 repeatCell
请求来更改 "data validation" 和 "user entered value" 属性所需的范围。关键是"fields"参数,表示要修改的属性,和实际的属性,都必须包含(或故意省略,删除)。
指定范围内的所有单元格(R2C19:R301C19,因为“_____Index”表示 -> 0 基)将被修改为使用您请求中找到的指定属性:
var resource = {"requests": [
{"repeatCell": {
"cell": {
"dataValidation": {"condition":{"type": "BOOLEAN"}},
"userEnteredValue": {"boolValue": true}
},
"range": {
"sheetId": sheetId,
"startRowIndex": 1,
"endRowIndex": 300,
"startColumnIndex": 18,
"endColumnIndex": 19 // Specify the end to insert only one column of checkboxes
},
"fields": "dataValidation,userEnteredValue"
}
}]};
Sheets.Spreadsheets.batchUpdate(resource, ss.getId());
请注意,如果您省略 endColumnIndex
,GridRange
将被解释为无界:
All indexes are zero-based. Indexes are half open, e.g the start index is inclusive and the end index is exclusive -- [startIndex
, endIndex
). Missing indexes indicate the range is unbounded on that side.
参考文献:
我正在使用此请求代码将这些复选框插入列中,但我还需要将它们全部默认设置为 true。到目前为止,我已经看到了多个 "values" 的例子,每行一个,但我想知道是否有一种方法可以只声明一次并且已经为范围
中的所有其他人设置var resource = {"requests": [
{"repeatCell": {
"cell": {"dataValidation": {"condition":{"type": "BOOLEAN"}}},
"range": {"sheetId": sheetId, "startRowIndex": 1, "endRowIndex": 300, "startColumnIndex": 18},
"fields": "dataValidation"
}
},
{"updateCells": {
"rows": {"values": {"userEnteredValue": {"boolValue": true}}},
"range": {"sheetId": sheetId, "startRowIndex": 1, "endRowIndex": 300, "startColumnIndex": 18},
"fields": "userEnteredValue"
}
}
]};
Sheets.Spreadsheets.batchUpdate(resource, ss.getId());
与其同时使用 repeatCell
和 updateCells
请求,不如使用单个 repeatCell
请求来更改 "data validation" 和 "user entered value" 属性所需的范围。关键是"fields"参数,表示要修改的属性,和实际的属性,都必须包含(或故意省略,删除)。
指定范围内的所有单元格(R2C19:R301C19,因为“_____Index”表示 -> 0 基)将被修改为使用您请求中找到的指定属性:
var resource = {"requests": [
{"repeatCell": {
"cell": {
"dataValidation": {"condition":{"type": "BOOLEAN"}},
"userEnteredValue": {"boolValue": true}
},
"range": {
"sheetId": sheetId,
"startRowIndex": 1,
"endRowIndex": 300,
"startColumnIndex": 18,
"endColumnIndex": 19 // Specify the end to insert only one column of checkboxes
},
"fields": "dataValidation,userEnteredValue"
}
}]};
Sheets.Spreadsheets.batchUpdate(resource, ss.getId());
请注意,如果您省略 endColumnIndex
,GridRange
将被解释为无界:
All indexes are zero-based. Indexes are half open, e.g the start index is inclusive and the end index is exclusive -- [
startIndex
,endIndex
). Missing indexes indicate the range is unbounded on that side.
参考文献: