此文档不支持此操作 - 表格 API

This operation is not supported for this document - Sheets API

(, https://sheets.googleapis.com/v4/spreadsheets/1IcMY2TNLYZtGyKO_zcrhP1MudNFXbNdM/values/P%C3%A1gina1%21A%3AP?alt=json returned "This operation is not supported for this document">, )

我在 Google 表格中访问电子表格时收到此错误消息,我知道发生此错误是因为它托管在 google 驱动器上并且采用 xlsx 格式。有谁知道直接在代码中执行从 xlsx 到 gsheet 的转换的任何替代方法?

是的,您可以将 .xlsx 转换为 Google 表格

为此,使用方法 Drive v2 method Files: Copy 指定 convert true

样本:

service.files().copy(fileId=file_id,convert=true, body={"title": "specifyName"}).execute()