Google Sheet + App script:如何使用数组为每个循环

伊万

嗨,我正在尝试获取一个脚本,该脚本将为从我的'sheet1'专栏创建的列表中的每个名称运行一些代码'A2:A'

1. get the list from Column A2:A
2. run code for each name from the list

这是我的代码,但它不能正常工作我认为数组没有正确填充

function test(){
var sheet = SpreadsheetApp.getActive().getSheetByName('sheet1');
var list = sheet.getRange('A2:A').getValues();
var a = [list];
a.forEach(function(entry) {
    
  //do something

 });
}
刘易斯

样品表

function test(){
    var sheet = SpreadsheetApp.getActive().getSheetByName('Sheet1');
    var lastSourceRow = sheet.getLastRow();//get last row
    for (i=2; i<=lastSourceRow; i++){//ignore headers and loop 
      var currentName=sheet.getRange(i, 1).getValue(); //looping column A 
      console.log(currentName)
      //process the name 
    }
    
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

无法将数组从 Google Web App 设置为 Google Sheet

如何在App Script for Google Sheet中创建数组的真实新副本?

如何通过 Google App Script 在 Google Sheet Range 中获得绝对 A1 表示法

Google Sheet 数组公式

在 Google Sheet App 脚本中寻找价值

使用 App Script 从 Google Sheet 下载文本文件

如何基于单元格值将数据从Google Sheet显示到Google Web App?

如何使用 google sheet app 脚本在单元格上添加评论

为什么 Google Sheet App Script 中的循环在循环过程中停止并且其余代码不运行?

Google Sheet Script - 多个 getRange 循环

LEFT OUTER JOIN 2 sheet using 1 column via Google App Script

到 toLocaleString 的 Google Sheet App Script 返回 M01 而不是一月

如何在Power App中将Google Sheet Excel列值添加到下拉列表

如何在Google Sheet App脚本中计算剩余时间

Google Sheet App Scripts:如何將工作表 A 列 A 中的 JSON 解析到工作表 B?

使用密钥/密码/密码保护“ Google Sheet Web App” API的安全

通过 Google Script 启用 Google Sheet Protection

Google App Script 循环遍历值数组

从Google Sheet到Web App显示匹配值时出错

在 Google Sheet 中循环创建 PDF

Google Sheet Script 不断追加空白列

Google Script - 从 Gmail 获取数据到 Sheet

在 Google Sheet 中查询条件数组

如何从 Google Sheet 中的元素更新表单?

如何从Google Sheet API导出csv?

如何参考 Google Sheet 中的字段?

使用 Jolt 简化 Google Sheet JSON

使用 API 在 Google Sheet 中写入的问题

使用 Google Sheet 作为网络服务