TableCollection: addTableCollection: add

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

创建一个新表。区域源地址确定将在其下添加表的工作表。如果无法添加表(例如,由于地址无效,或者表与另一个表重叠),将抛出错误。Create a new table. The range source address determines the worksheet under which the table will be added. If the table cannot be added (e.g., because the address is invalid, or the table would overlap with another table), an error will be thrown.

错误处理Error Handling

此请求有时可能会收到 504 HTTP 错误。This request might occasionally receive a 504 HTTP error. 此错误的适当响应做法是重复发出请求。The appropriate response to this error is to repeat the request.


要调用此 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/add
POST /workbook/worksheets/{id|name}/tables/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 表示数据源的 range 对象的地址或名称。如果该地址不包含工作表名称,则使用当前活动的工作表。Address or name of the range object representing the data source. If the address does not contain a sheet name, the currently-active sheet is used.
hasHeadershasHeaders booleanboolean 指示导入的数据是否具有列标签的布尔值。如果源不包含标头(即,当此属性设置为 false 时),Excel 将自动生成标头,数据将向下移动一行。Boolean value that indicates whether the data being imported 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.


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


下面是一个如何调用此 API 的示例。Here is an example of how to call this API.


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

Content-type: application/json
Content-length: 54

  "address": "Sheet1!A1:D5",
  "hasHeaders": true

下面是一个响应示例。注意:为了简单起见,可能会将此处所示的响应对象截断。将从实际调用中返回所有属性。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: 109

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