【问题标题】:How to capture A1 notation in Google Apps Scripts for Google Sheets如何在 Google 表格的 Google Apps 脚本中捕获 A1 符号
【发布时间】:2017-03-03 16:51:07
【问题描述】:

我使用以下代码块将下拉框插入到我的一个单元格中。我想用行号和列号替换 A10。

所以有两件事我想做。要么

a> 想办法做 SpreadsheetApp.getActive().getRange(1,10) 或

b> 如果有办法我可以使用 Excel 之类的符号来获取我的单元格的位置。我的意思是,如果我的单元格 A10 包含值“测试”,我想找出“测试”在我的 Google 电子表格中所在位置的单元格详细信息 (A10)。他们中的任何一个都会帮助我。

var cell = SpreadsheetApp.getActive().getRange('A10');
var rule = SpreadsheetApp.newDataValidation().
           requireValueInList(['Yes', 'No'], true).build();
cell.setDataValidation(rule);

【问题讨论】:

  • 也许你最好检查thisthis或类似的问题。

标签: google-apps-script google-sheets


【解决方案1】:
var cell = SpreadsheetApp.getActive().getRange('A10');

上面的行应该是:

var cell = SpreadsheetApp.getActiveSheet().getRange('A10');

var cell = SpreadsheetApp.getActive().getRange('Sheet1!A10');

或者无论你的工作表名称是什么。

【讨论】:

  • 我不知道你是否打算回答我的问题,但这不是我想要的。
  • 我只是指出了您的代码中的一个错误并提出了两个替代方案。
  • 所以也许您想了解文档 Ranges 页面上的 getA1Notation() 函数
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-11-16
  • 1970-01-01
  • 1970-01-01
  • 2022-10-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多