更新区域Update range

命名空间:microsoft.graphNamespace: microsoft.graph

更新 range 对象的属性。Update the properties of range object.

权限Permissions

要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.

权限类型Permission type 权限(从最低特权到最高特权)Permissions (from least to most privileged)
委派(工作或学校帐户)Delegated (work or school account) Files.ReadWriteFiles.ReadWrite
委派(个人 Microsoft 帐户)Delegated (personal Microsoft account) 不支持。Not supported.
应用程序Application 不支持。Not supported.

HTTP 请求HTTP request

PATCH /workbook/names/{name}/range
PATCH /workbook/worksheets/{id|name}/range(address='<address>')
PATCH /workbook/tables/{id|name}/columns/{id|name}/range

可选的请求标头Optional request headers

名称Name 说明Description
AuthorizationAuthorization Bearer {token}。必需。Bearer {token}. Required.
Workbook-Session-IdWorkbook-Session-Id 确定是否保留更改的工作簿会话 ID。可选。Workbook session Id that determines if changes are persisted or not. Optional.

请求正文Request body

在请求正文中,提供应更新的相关字段的值。请求正文中不包括的现有属性将保留其以前的值,或根据对其他属性值的更改重新计算。为了获得最佳性能,不应包括尚未更改的现有值。In the request body, supply the values for relevant fields that should be updated. Existing properties that are not included in the request body will maintain their previous values or be recalculated based on changes to other property values. For best performance you shouldn't include existing values that haven't changed.

属性Property 类型Type 说明Description
columnHiddencolumnHidden booleanboolean 表示当前区域中的所有列是否隐藏。Represents if all columns of the current range are hidden.
formulasformulas JsonJson 表示采用 A1 表示法的公式。Represents the formula in A1-style notation.
formulasLocalformulasLocal JsonJson 表示采用 A1 样式表示法的公式,使用用户的语言和数字格式区域设置。例如,英语中的公式 "=SUM(A1, 1.5)" 在德语中将变为 "=SUMME(A1; 1,5)"。Represents the formula in A1-style notation, in the user's language and number-formatting locale. For example, the English "=SUM(A1, 1.5)" formula would become "=SUMME(A1; 1,5)" in German.
formulasR1C1formulasR1C1 JsonJson 表示采用 R1C1 样式表示法的公式。Represents the formula in R1C1-style notation.
numberFormatnumberFormat JsonJson 表示 Excel 中指定单元格的数字格式代码。Represents Excel's number format code for the given cell.
rowHiddenrowHidden booleanboolean 表示当前区域中的所有行是否隐藏。Represents if all rows of the current range are hidden.
valuesvalues JsonJson 表示指定区域的原始值。返回的数据类型可能是字符串、数字或布尔值。包含一个将返回错误字符串的错误的单元格。Represents the raw values of the specified range. The data returned could be of type string, number, or a boolean. Cell that contain an error will return the error string.

响应Response

如果成功,此方法在响应正文中返回 200 OK 响应代码和更新的 Range 对象。If successful, this method returns a 200 OK response code and updated Range object in the response body.

示例Example

请求Request

下面是一个请求示例。该示例更新区域 - 值、数字格式和公式。null 输入是为了指示 API 忽略单元格的特定输入。值、数字格式和公式可以独立更新,也可以在同一 API 调用中共同更新。Here is an example of the request. It updates a range - values, number-format and formula. The null input is to instruct the API to ignore the cell for that particular input. The values, number-format and formulas can be independently updated or combined together in the same API call.

PATCH https://graph.microsoft.com/v1.0/me/drive/items/{id}/workbook/worksheets/{sheet-id}/range(address='A1:B2')
Content-type: application/json
Content-length: 169

{
"values" : [["Hello", "100"],["1/1/2016", null]],
"formulas" : [[null, null], [null, "=B1*2"]],
"numberFormat" : [[null,null], ["m-ddd", null]]
}
响应Response

下面是一个响应示例。注意:为了简单起见,可能会将此处所示的响应对象截断。将从实际调用中返回所有属性。Here is an example of the response. Note: The response object shown here may be truncated for brevity. All of the properties will be returned from an actual call.

HTTP/1.1 200 OK
Content-type: application/json
Content-length: 169

{
  "address": "address-value",
  "addressLocal": "addressLocal-value",
  "cellCount": 99,
  "columnCount": 99,
  "columnIndex": 99,
  "valueTypes": "valueTypes-value"
}