【问题标题】:Is there any REST API for creating new Excel (.xlsx) file in OneDrive cloud是否有任何 REST API 用于在 OneDrive 云中创建新的 Excel (.xlsx) 文件
【发布时间】:2021-05-21 03:54:54
【问题描述】:

我正在尝试使用 REST API 调用的以下属性在 OneDrive 中创建一个新的 excel 文件。

网址:https://graph.microsoft.com//v1.0/me/drive/root/children 正文:

{
    "name": "MyFile.xlsx",
    "file": {},
    "@microsoft.graph.conflictBehavior": "rename"
}

标题: 内容类型:application/json

借助上述属性,我可以在 OneDrive 中创建文件。 但它的创建没有大小&如果我尝试打开它说的工作簿 无法打开工作簿 错误 无法打开工作簿。

基本上,每当我从 UI 创建一个新的 excel 文件时,它的默认大小为 7.81KB(可用于文件的元数据)。

我参考了https://docs.microsoft.com/en-us/graph/api/driveitem-post-children?view=graph-rest-1.0&tabs=http

有谁知道如何解决这个问题?

【问题讨论】:

    标签: excel microsoft-graph-api onedrive microsoft-graph-teams microsoft-graph-files


    【解决方案1】:

    Graph API 不支持创建空的 Excel 文件。唯一的方法是从本地存储上传一个空的 excel 文件或复制在 OneDrive 中创建的一个空的 excel 文件。

    我正在使用第二种方式。我在 OneDrive 中有一个用于 excel 文件的空模板,并通过调用端点从该模板创建一个新的 excel 文件

    POST  https://graph.microsoft.com/v1.0/me/drive/items/{template_item-id}/copy
    

    Copy item

    【讨论】:

    • 但是每个新用户的 Onedrive 中都不会有空的 excel 文件。
    • @HarshadPanmand 空的excel文件可以存储在OneDrive的某个共享文件夹中,所有用户都可以访问。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-10
    • 1970-01-01
    • 2019-12-03
    • 2017-02-28
    相关资源
    最近更新 更多