我们在哪里可以找到Google Objects的未记录属性 [英] Where can we find non-documented attributes of Google Objects

查看:61
本文介绍了我们在哪里可以找到Google Objects的未记录属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道自动完成有时可以帮助您找到Google对象的未引用方法,例如 Sheets API v4 ,但是我如何找到属性.

I know that auto-completion sometimes helps you find unreferenced methods of Google objects such as for the Sheets API v4 but how can I find the attributes.

电子表格示例:

function onEdit(e)
{
  Logger.log(e.range.columnStart)
  //returns the start column of the range I've edited
  Logger.log(SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getDataRange().columnStart)
  //Weird result, even if my sheet is populated with values it returns 'undefined'
}

在此示例中,您看到了属性columnStart,但是我在文档中找不到它,但是很多人似乎都在使用它.

In this example you see the attribute columnStartbut I can't find it in documentation however a lot of people seems to use it.

另一点可能没有主题,但很有趣,e.rangegetDataRange都返回了一个Range对象,但是当另一个没有时,它似乎填充了columnStart属性.

Another point that can be out of subject but interesting, both e.range and getDataRange returns a Range object but one seems to have a populated columnStartattribute when the other don't.

推荐答案

  • 您要从onEdit(e)检索e.range的对象.
    • You want to retrieve the object of e.range from onEdit(e).
    • 如果我的理解是正确的,那么这个答案如何?不幸的是,详细信息属性在事件对象"文档中看不到.因此,例如,它使用JSON.stringify()确认了事件对象的每个属性.

      If my understanding is correct, how about this answer? Unfortunately, the detail properties cannot seen at the document of Event Objects. So, for example, it confirms each properties from the event object using JSON.stringify().

      function onEdit(e) {
        Logger.log(JSON.stringify(e)) // or console.log(JSON.stringify(e))
      }
      

      结果:

      {
        "authMode": {},
        "range": {
          "columnStart": 1,
          "rowStart": 1,
          "rowEnd": 1,
          "columnEnd": 1
        },
        "source": {},
        "user": {
          "nickname": "### name ###",
          "email": "### email ###"
        },
        "value": "sample"
      }
      

      注意:

      • 如果运行Logger.log(JSON.stringify(e.range)),则检索{"columnStart":1,"rowStart":1,"rowEnd":1,"columnEnd":1}.在这种情况下,将编辑"A1".
      • Note:

        • If Logger.log(JSON.stringify(e.range)) is run, {"columnStart":1,"rowStart":1,"rowEnd":1,"columnEnd":1} is retrieved. In this case, "A1" is edited.
        • 这篇关于我们在哪里可以找到Google Objects的未记录属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆