[英]Writing the values in Google Sheet column via Apps Script
I have a 2 column google sheet, column one (A) has the domain names, and I want to populate whether they are verified in Google Apps or not in the column B respectively. 我有一个2列的Google工作表,其中的第一列(A)具有域名,我想分别在B列中填充它们是否已在Google Apps中验证。
I wrote the following script-: When i check for logs, i see that the loop is working fine as i get True/False value to all 4 domain in column A, am facing issues in writing the results to Column B with following script, it seems am missing something around getrange, but not sure. 我编写了以下脚本::当我检查日志时,我看到循环正常运行,因为我对A列中的所有4个域都获得了True / False值,在使用以下脚本将结果写入B列时遇到了问题,似乎缺少getrange周围的东西,但不确定。 any help is appreciated.
任何帮助表示赞赏。
var ss = SpreadsheetApp.getActiveSpreadsheet()
var data = ss.getSheets()[0].getDataRange().getValues();
var customer = "my_customer";
function domainList() {
for(i=0; i<data.length; i++){
var getDomain = AdminDirectory.Domains.get(customer, data[i])
var result = JSON.parse(getDomain.verified)
sheet.getRange('B1').setValue(result)
Logger.log(result)
} }
I think you need to define sheet. 我认为您需要定义工作表。
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = SpreadsheetApp.getActiveSheet();
var data = ss.getSheets()[0].getDataRange().getValues();
var customer = "my_customer";
function domainList() {
for(i=0; i<data.length; i++){
var getDomain = AdminDirectory.Domains.get(customer, data[i])
var result = JSON.parse(getDomain.verified)
sheet.getRange('B1').setValue(result)
Logger.log(result)
} }
I think if you will recode your function like this it will work okay. 我认为,如果您将像这样重新编码函数,它将可以正常工作。 I disabled a couple of lines just to get the code right.
为了使代码正确,我禁用了几行。
function domainList()
{
var sheet = SpreadsheetApp.getActiveSheet();
var data =sheet.getDataRange().getValues();
var customer = "my_customer";
for(i=0; i<data.length; i++)
{
data[i]=[];
//var getDomain = AdminDirectory.Domains.get(customer, data[i][0]);
//var result = JSON.parse(getDomain.verified)
sheet.getRange(i+1,2).setValue('yes')
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.