google-apps-script - Sheet.getRange(1,1,1,12) 括号中的数字表示什么?

标签 google-apps-script google-sheets google-spreadsheet-api

Sheet.getRange(1,1,1,12)

我无法理解这些论点 1,1,1,12 .这是什么 - 工作表 ID 或行或什么?
method getRange(row, column, optNumRows, optNumColumns)

这里有什么optNumRowsoptNumColumns意思???

最佳答案

google docu pages 上找到这些文档:

  • row --- int --- 范围的顶行
  • column --- int--- 范围最左边的列
  • optNumRows --- int --- 范围内的行数。
  • optNumColumns --- int --- 范围内的列数

  • 在您的示例中,您会得到(如果您选择第三行)“C3:O3”,原因 C --> O 是 12 列
    编辑
    使用文档上的示例:

    // The code below will get the number of columns for the range C2:G8
    // in the active spreadsheet, which happens to be "4"
    var count = SpreadsheetApp.getActiveSheet().getRange(2, 3, 6, 4).getNumColumns(); Browser.msgBox(count);


    括号之间的值:
    2:起始行 = 2
    3:起始col = C
    6:行数 = 6 所以从 2 到 8
    4:cols 的数量 = 4 所以从 C 到 G
    所以你来到了范围:C2:G8

    关于google-apps-script - Sheet.getRange(1,1,1,12) 括号中的数字表示什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11947590/

    相关文章:

    google-apps-script - 在谷歌表中嵌入 html

    google-apps-script - 启用 Google API OAuth 范围

    google-apps-script - 如何暂停谷歌脚本中的onEdit功能

    python - 使用其 API 和 Python 在 Google 表格电子表格中设置单元格格式

    javascript - 仅在谷歌驱动器中使用谷歌表格作为数据库

    javascript - Google 脚本 - 在 html 上显示根据 google.gs 函数计算的结果

    javascript - 设置新单元格值时保留格式(Google 电子表格)

    javascript - 库定义的 Google Sheets 菜单

    regex - 谷歌表格上的模糊匹配

    google-apps-script - Google脚本: Conditionally copy rows from one sheet to another in the same spreadsheet