更新 RangeFormatUpdate rangeformat

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

重要

/betaMicrosoft Graph 中的版本下的 api 可能会发生更改。APIs under the /beta version in Microsoft Graph are subject to change. 不支持在生产应用程序中使用这些 API。Use of these APIs in production applications is not supported. 若要确定 API 在 v1.0 中是否可用,请使用 版本 选择器。To determine whether an API is available in v1.0, use the Version selector.

更新 rangeformat 对象的属性。Update the properties of rangeformat 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) Files.ReadWriteFiles.ReadWrite
应用程序Application 不支持。Not supported.

HTTP 请求HTTP request

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

可选的请求标头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
columnWidthcolumnWidth doubledouble 获取或设置区域内的所有列的宽度。如果列宽不统一,则返回 NULL。Gets or sets the width of all colums within the range. If the column widths are not uniform, null will be returned.
horizontalAlignmenthorizontalAlignment stringstring 表示指定对象的水平对齐方式。可能的值是:GeneralLeftCenterRightFillJustifyCenterAcrossSelectionDistributedRepresents the horizontal alignment for the specified object. Possible values are: General, Left, Center, Right, Fill, Justify, CenterAcrossSelection, Distributed.
rowHeightrowHeight doubledouble 获取或设置区域中所有行的高度。如果行高不统一,则返回 NULL。Gets or sets the height of all rows in the range. If the row heights are not uniform null will be returned.
verticalAlignmentverticalAlignment stringstring 表示指定对象的垂直对齐方式。可能的值是:TopCenterBottomJustifyDistributedRepresents the vertical alignment for the specified object. Possible values are: Top, Center, Bottom, Justify, Distributed.
wrapTextwrapText booleanboolean 指示 Excel 是否将对象中的文本换行。指示整个区域不具有统一换行设置的空值Indicates if Excel wraps the text in the object. A null value indicates that the entire range doesn't have uniform wrap setting

响应Response

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

示例Example

更新三个表格单元格的格式、填充和字体属性Update the format, fill, and font properties in three table cells

下面的示例演示如何更新指定区域的 workbookRangeFormatworkbookRangeFillworkbookRangeFont 属性的属性。The following examples demonstrate how to update properties of the workbookRangeFormat, workbookRangeFill, and workbookRangeFont properties of a specified range.

这组请求的结果是一个表格,其中的三个单元格的格式如下图中的前三个单元格所示。The result of this set of requests is a table with three cells formatted like the top three cells in the image below.

其中的三个单元格的格式、填充和字体属性已更新的 Excel 图表表格。

请求Request

此请求更新第一个单元格的垂直对齐方式、行高和列高。This request updates the vertical alignment, row height, and column height of the first cell.

PATCH https://graph.microsoft.com/beta/me/drive/items/{id}/workbook/worksheets/Sheet1/range(address='$A$1')/format
Content-type: application/json

{
  "columnWidth": 135,
  "verticalAlignment": "Top",
  "rowHeight": 49,
  "wrapText": false
}
响应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

{
    "columnWidth": 135,
    "horizontalAlignment": "General",
    "rowHeight": 49,
    "verticalAlignment": "Top",
    "wrapText": false
}
请求Request

此请求更新第一个单元格的字形、大小和颜色。This request updates the font style, size, and color of the first cell.

PATCH https://graph.microsoft.com/beta/me/drive/items/{id}/workbook/worksheets/Sheet1/range(address='$A$1')/format/font
Content-type: application/json

{
  "bold": true,
  "color": "#4B180E",
  "size": 26
}
响应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

{
    "bold": true,
    "color": "#4B180E",
    "italic": false,
    "name": "Calibri",
    "size": 26,
    "underline": "None"
}
请求Request

此请求更新第一个单元格的背景色。This request updates the background color of the first cell.

PATCH https://graph.microsoft.com/beta/me/drive/items/{id}/workbook/worksheets/Sheet1/range(address='$A$1')/format/fill
Content-type: application/json

{
  "color": "#FF0000"
}
响应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

{
    "color": "#FF0000"
}
请求Request

此请求更新第二个单元格的垂直对齐方式、水平对齐方式、行高和列高。This request updates the vertical alignment, horizontal alignment, row height, and column height of the second cell.

PATCH https://graph.microsoft.com/beta/me/drive/items/{id}/workbook/worksheets/Sheet1/range(address='$B$1')/format
Content-type: application/json

{
  "columnWidth": 135,
  "horizontalAlignment": "Center",
  "verticalAlignment": "Center",
  "rowHeight": 49,
  "wrapText": false
}
响应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

{
    "columnWidth": 135,
    "horizontalAlignment": "Center",
    "rowHeight": 49,
    "verticalAlignment": "Center",
    "wrapText": false
}
请求Request

此请求更新第二个单元格的字形和大小。This request updates the font style and size of the second cell.

PATCH https://graph.microsoft.com/beta/me/drive/items/{id}/workbook/worksheets/Sheet1/range(address='$B$1')/format/font
Content-type: application/json

{
  "italic": true,
  "size": 26
}
响应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

{
    "bold": false,
    "color": "#000000",
    "italic": true,
    "name": "Calibri",
    "size": 26,
    "underline": "None"
}
请求Request

此请求更新第二个单元格的背景色。This request updates the background color of the second cell.

PATCH https://graph.microsoft.com/beta/me/drive/items/{id}/workbook/worksheets/Sheet1/range(address='$B$1')/format/fill
Content-type: application/json

{
  "color": "#00FF00"
}
响应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

{
    "color": "#00FF00"
}
请求Request

此请求更新第三个单元格的水平对齐方式、垂直对齐方式、行高和列高。This request updates the horizontal alignment, vertical alignment, row height, and column height of the third cell.

PATCH https://graph.microsoft.com/beta/me/drive/items/{id}/workbook/worksheets/Sheet1/range(address='$C$1')/format
Content-type: application/json

{
  "columnWidth": 135,
  "horizontalAlignment": "Right",
  "verticalAlignment": "Top",
  "rowHeight": 49,
  "wrapText": false
}
响应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

{
    "columnWidth": 135,
    "horizontalAlignment": "Right",
    "rowHeight": 49,
    "verticalAlignment": "Top",
    "wrapText": false
}
请求Request

此请求更新第三个单元格的字形、大小和颜色。This request updates the font style, size, and color of the third cell. 请注意,下划线属性采用作为值。Note that the underline property takes Single or Double as values.

PATCH https://graph.microsoft.com/beta/me/drive/items/{id}/workbook/worksheets/Sheet1/range(address='$C$1')/format/font
Content-type: application/json

{
  "underline": "Single",
  "color": "#FFFFFF",
  "size": 26
}
响应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

{
    "bold": false,
    "color": "#FFFFFF",
    "italic": false,
    "name": "Calibri",
    "size": 26,
    "underline": "Single"
}
请求Request

此请求更新第三个单元格的背景色。This request updates the background color of the third cell.

PATCH https://graph.microsoft.com/beta/me/drive/items/{id}/workbook/worksheets/Sheet1/range(address='$C$1')/format/fill
Content-type: application/json

{
  "color": "#0000FF"
}
响应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

{
    "color": "#0000FF"
}