Method: spreadsheets.values.clear
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
清除电子表格中的值。调用方必须指定电子表格 ID 和范围。系统只会清除值,单元格的所有其他属性(例如格式、数据验证等)都会保留。
HTTP 请求
POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}:clear
网址采用 gRPC 转码语法。
路径参数
参数 |
spreadsheetId |
string
要更新的电子表格的 ID。
|
range |
string
要清除的值的 A1 表示法或 R1C1 表示法。
|
响应正文
清除电子表格中一组值时的响应。
如果成功,响应正文将包含结构如下的数据:
JSON 表示法 |
{
"spreadsheetId": string,
"clearedRange": string
} |
字段 |
spreadsheetId |
string
应用了更新的电子表格。
|
clearedRange |
string
已清除的范围(采用 A1 表示法)。(如果请求的范围无界或超出工作表的边界,则此值将是清除的实际范围,并受工作表边界的限制。)
|
授权范围
需要以下 OAuth 范围之一:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/spreadsheets
如需了解详情,请参阅授权指南。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-22。
[null,null,["最后更新时间 (UTC):2025-03-22。"],[],[],null,["# Method: spreadsheets.values.clear\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Path parameters](#body.PATH_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n - [JSON representation](#body.ClearValuesResponse.SCHEMA_REPRESENTATION)\n- [Authorization scopes](#body.aspect)\n- [Try it!](#try-it)\n\nClears values from a spreadsheet. The caller must specify the spreadsheet ID and range. Only values are cleared -- all other properties of the cell (such as formatting, data validation, etc..) are kept.\n\n### HTTP request\n\n`POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}:clear`\n\nThe URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.\n\n### Path parameters\n\n| Parameters ||\n|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------|\n| `spreadsheetId` | `string` The ID of the spreadsheet to update. |\n| `range` | `string` The [A1 notation or R1C1 notation](https://developers.google.com/workspace/sheets/api/guides/concepts#cell) of the values to clear. |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nThe response when clearing a range of values in a spreadsheet.\n\nIf successful, the response body contains data with the following structure:\n\n| JSON representation |\n|-------------------------------------------------------------|\n| ``` { \"spreadsheetId\": string, \"clearedRange\": string } ``` |\n\n| Fields ||\n|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `spreadsheetId` | `string` The spreadsheet the updates were applied to. |\n| `clearedRange` | `string` The range (in A1 notation) that was cleared. (If the request was for an unbounded range or a ranger larger than the bounds of the sheet, this will be the actual range that was cleared, bounded to the sheet's limits.) |\n\n### Authorization scopes\n\nRequires one of the following OAuth scopes:\n\n- `https://www.googleapis.com/auth/drive`\n- `https://www.googleapis.com/auth/drive.file`\n- `https://www.googleapis.com/auth/spreadsheets`\n\nFor more information, see the [Authorization guide](/workspace/guides/configure-oauth-consent)."]]