我已经能够从Google表格上的导入和实时更新的postgres导入中添加新的一行数据。我的要求是将数据附加到新列中,紧接在前一个列之后。
// function to save data
function saveData() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var count = sheet.getRange('Sheet1!A3').getValue();
var date = sheet.getRange('Sheet1!B3').getValue();
sheet.insertColumnAfter(sheet.getMaxColumns());
sheet.getRange(1,sheet.getLastColumn(),2).setValues([count,date]);
}
出现无法将对象转换为数组的错误-有帮助吗?
答案 0 :(得分:0)
function append() {
var tabLists = "append"; //my sheet is named as "append"
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(tabLists);
sheet.clear()
var date = new Date('October 11, 2018 09:15:00')
var sr = 4
var sft = 1
var sc = 1
var nr = 1
var nc = 1
for(var i=0; i<5;i++){ //I'm appendind 5 columns for now.
sheet.getRange(sr,sc,nr,nc)//(start row, start column, number of rows, number of
columns)
.setValues([[
date
]]);
sc = sc + 1
}
}