【问题标题】:Read Google Spreadsheets conditonal format information阅读 Google 电子表格条件格式信息
【发布时间】:2019-04-05 13:02:55
【问题描述】:

我希望阅读带有脚本的谷歌电子表格条件格式信息。我这样做如下:

function readConditionalFormatInfo() {
  var url = "https://sheets.googleapis.com/v4/spreadsheets/spreadsheetId?fields=sheets(properties(title,sheetId),conditionalFormats)"
  var response = UrlFetchApp.fetch(url)
  Logger.log(response)
}

但发生错误:

Request failed for https://sheets.googleapis.com/v4/spreadsheets/spreadsheetId?fields=sheets(properties(title,sheetId),conditionalFormats) returned code 403. Truncated server response: { "error": { "code": 403, "message": "The request is missing a valid API key.", "status": "PERMISSION_DENIED" } } (use muteHttpExceptions option to examine full response) (line 214, file "Code")

也许我不应该在 GAS 中运行 REST API,但我不知道如何在脚本中执行它!

如果有人可以提供帮助,不胜感激!

【问题讨论】:

    标签: google-sheets-api


    【解决方案1】:

    如下所示:

    function readConditionalFormat() {
      var sheet = SpreadsheetApp.getActive().getActiveSheet();
      var rules = sheet.getConditionalFormatRules();
      if (rules != null) {
        for (var i=0;i<rules.length;i++) {
          var rule = rules[i].getBooleanCondition()
          var criteria = rule.getCriteriaType()
          var value = rule.getCriteriaValues()
          var bakcolor = rule.getBackground()
          Logger.log(criteria+ " -> " + value + ":" + bakcolor);
        }
      } else {
        Logger.log('Conditional Format rule null')
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-12-09
      • 1970-01-01
      • 2012-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-11
      • 1970-01-01
      相关资源
      最近更新 更多