如何通过API创建一个空的Excel工作簿?

我正在尝试使用Microsoft Graph API在OneDrive中创建一个空的Excel工作簿。我尝试了各种请求,但OneDrive并未发现仅基于扩展名就是Excel。我发现的唯一示例是C#SDK示例,我正在寻找没有SDK的另一种语言

The following creates the file but creates it with a mime-type of application/octet-stream

PUT /v1.0/me/drive/items/root:/NewWorkbook.xlxs:/content HTTP/1.1
Host: graph.microsoft.com
Content-Type: application/json
Authorization: Bearer <REDACTED>

{
  "name": "NewWorkbook.xlxs",
  "file": {

  }
}

I found a similar ask from a few years ago but Microsoft Graph has undergone a lot of changes since then so I would assume the answers to be somewhat dated https://stackoverflow.com/a/38901596/10255083

评论
dnulla
dnulla

There is an office JS API called createWorkbook API, it can create an workbook, but it seems this API not yet expose to Excel Graph, therefore graph doesn't support create an empty workbook.

如果您具有excel加载项,则可以使用此API创建工作簿,而又不想打开该工作簿,则可以使用变通办法来复制预先保存的空工作簿,然后使用Graph API更新复制的工作簿。

点赞
评论