简体   繁体   English

Google Script - 每次使用 Google Sheets 上的 Apps 脚本运行脚本时增加数据范围

[英]Google Script - Increment the data range every time script is run using using Apps script on Google Sheets

I'm trying to create a list from one cell that is consistently updated in google sheets.我正在尝试从一个在谷歌表格中不断更新的单元格创建一个列表。

I have the following code inside my function.我的函数中有以下代码。

 var app = SpreadsheetApp;

var tS = app.getActiveSpreadsheet().getSheetByName("Dashboard");

var tempNum =  tS.getRange(18,11).getValue();

var ttS = app.getActiveSpreadsheet().getSheetByName("GraphData");

var ud = ttS.getRange('A1').setValue(tempNum);

How do I add the value stored in tempNum to a new row every time the script is executed?每次执行脚本时,如何将存储在tempNum中的值添加到新行?

I will then trigger the script once per day to set the new value into the row below and then create a graph from said values.然后,我将每天触发一次脚本,将新值设置到下面的行中,然后根据所述值创建一个图表。

Thanks in advance, let me know if any more information is needed.提前致谢,如果需要更多信息,请告诉我。

To append the value stored in tempNum to a new row at the end of the GraphData sheet every time the script is executed, use Sheet.appendRow() , like this:要在每次执行脚本时将存储在tempNum中的值附加到GraphData表末尾的新行,请使用Sheet.appendRow() ,如下所示:

  ttS.appendRow([tempNum]);

See Apps Script at Stack Overflow .请参阅Stack Overflow 上的 Apps 脚本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM