【问题标题】:Validate google spreadsheet ID in appscript在应用程序脚本中验证 google 电子表格 ID
【发布时间】:2020-12-28 06:08:53
【问题描述】:

我想知道是否有办法在 Appscript 中检查字符串是否是谷歌电子表格 ID

例如,如果我有一个文本框,用户可以在其中输入电子表格 ID。

EG:1eNLkH_uhLbKktETgiqi0A6kmVQ_AgrvdQ2ZeS_sVYOk

appscript 中是否有任何方法可以检查输入的字符串是否为有效的电子表格 ID,或者至少是否通过了电子表格 ID 的标准。

【问题讨论】:

    标签: google-apps-script


    【解决方案1】:

    你可以使用SpreadsheetApp.openById():

    const isIdSpreadsheet = id => {
      try {
        SpreadsheetApp.openById(id);
        return true;
      } catch (e) {
        return false;
      }
    };
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-22
      • 2016-12-21
      • 2022-08-05
      • 1970-01-01
      • 2015-09-10
      相关资源
      最近更新 更多