创建表Create table

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

使用此 API 创建新的表。Use this API to create a new Table.

权限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

POST /workbook/tables/{table-id}/add

请求标头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

在请求正文中,提供具有以下参数的 JSON 对象。In the request body, provide a JSON object with the following parameters.

参数Parameter 类型Type 说明Description
AddressAddress stringstring 区域地址。若要从 worksheets/{id or name}/tables/add 路径调用此 API,地址中无需有工作表名称前缀。不过,若要从 workbook/tables/add 路径调用此 API,请提供需要在其中创建表的工作表名称(例如:sheet1!A1:D4Range address. If you are calling this API off of worksheets/{id or name}/tables/add path, there is no need to for sheet name prefix in the address. However, if you are calling this off of workbook/tables/add path, then supply the sheet name on which the table needs to be created (example: sheet1!A1:D4)
hasHeadershasHeaders 布尔boolean 指示区域是否具有列标签的布尔值。如果源不包含标头(即,当此属性设置为 false 时),Excel 将自动生成标头,数据将向下移动一行。Boolean value that indicates whether the range has column labels. If the source does not contain headers (i.e,. when this property set to false), Excel will automatically generate header shifting the data down by one row.

响应Response

如果成功,此方法在201 Created响应正文中返回响应代码和WorkbookTable对象。If successful, this method returns 201 Created response code and WorkbookTable object in the response body.

示例Example

请求Request

下面是一个请求示例。Here is an example of the request.

POST https://graph.microsoft.com/v1.0/me/drive/items/{id}/workbook/tables/{table-id}/add
Content-type: application/json
Content-length: 109

{
  "address": "A1:D8",
  "hasHeaders": 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 201 Created
Content-type: application/json
Content-length: 109

{
  "id": "99",
  "name": "name-value",
  "showHeaders": true,
  "showTotals": true,
  "style": "style-value"
}