[英]Append to the last row starting from a specific column
I have a code written code.gs of Google App script like this我有一个这样的 Google App 脚本的代码编写 code.gs
function enterAmount(inputInfo){
var url = 'https://docs.google.com/spreadsheets/d/1bM8l6JefFsPrlJnTWf56wOhnuSjdIwg3hMbY1tN1Zp8/edit#gid=1151242353';
var ss = SpreadsheetApp.openByUrl(url);
var ws = ss.getSheetByName("Payment Configuration");
var repeatedPayment = ( inputInfo.amount / 50 );
for(var i = 50; i <= repeatedPayment; i++){
ws.appendRow([inputInfo.uname,inputInfo.pm_hseno,inputInfo.streetName]);
}
}
The function is working fine but I just want to append the information starting from column E. I dont want it follow the last column of the whole sheet. function 工作正常,但我只想 append 从 E 列开始的信息。我不希望它跟随整个工作表的最后一列。 Can anyone help me modify the code?
谁能帮我修改代码? Thanks in advance.
提前致谢。
If you want to append row based on your last row in column E you can use getRange() last column and getDataRegion() instead.如果要根据 E 列中的最后一行 append 行,则可以使用 getRange() 最后一列和 getDataRegion() 代替。
I'm not sure what is your for loop is for though.我不确定你的 for 循环是做什么的。
function enterAmount(inputInfo){
var url = 'your URL';
var ss = SpreadsheetApp.openByUrl(url);
var ws = ss.getSheetByName("Payment Configuration");
var lastRow = ws.getRange("E1").getDataRegion().getLastRow() + 1;
var repeatedPayment = ( inputInfo.amount / 50 );
ws.getRange(lr,1,1,3).setValues([[inputInfo.uname,inputInfo.pm_hseno,inputInfo.streetName]]);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.