【问题标题】:How set major dimension in google spreadsheets api?如何在谷歌电子表格 api 中设置主要维度?
【发布时间】:2019-09-23 02:39:49
【问题描述】:

我需要使用 google 电子表格 API 设置 majorDimension 值。我已经阅读了文档,它只是说我可以将值设置为 ROW 或 COLUMN,但它没有说明如何在 URL 中执行此操作。

文档:https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values#dimension

URL:https://sheets.googleapis.com/v4/spreadsheets/!A1:C1(这里我设置majorDimension的值在哪里?)

【问题讨论】:

  • 您想在 Sheets API 中使用什么方法?

标签: spreadsheet google-sheets-api


【解决方案1】:

通过向请求的 url 添加majorDimension 值解决了这个问题。

这是 COLUMN Dimension

的示例
https://sheets.googleapis.com/v4/spreadsheets/{SpreadSheetID}/values/{Range}?majorDimension=COLUMNS&key={APIKey} 

对于行维度

https://sheets.googleapis.com/v4/spreadsheets/{SpreadSheetID}/values/{Range}?key={APIKey}

【讨论】:

    【解决方案2】:

    如果要更改工作表,需要使用update 方法。关注this documentation,它将向您解释如何制作请求,以及您只需要请求的正文:

    {
      "majorDimension": "ROWS"
    }
    

    请求如下所示:

    https://content-sheets.googleapis.com/v4/spreadsheets/SHEET_ID/values/A1%3AC2?valueInputOption=USER_ENTERED&alt=json&key=KEY

    我建议您在 update 方法页面(上面链接)中使用 try this API 选项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多