我需要获取一个数据表作为数组,执行一些处理,然后将其保存到另一个表中。
不尝试任何中间处理,
var booking = getRowsData(sheet); //should create the array
var range = target.getRange(lastDBRow+1,1,numRows); //obtains the destination range (numRows logged as 3)
然后
range.setValues([booking]); //tries to save the values but throws an error "Incorrect range height, was 1 but should be 3"
使用
检查预订对象var response = ui.prompt(booking.length + " " + booking[0].length, ui.ButtonSet.OK);
显示长度3和 booking [0] .length(我理解为列)为未定义。...
那么为什么行长度不匹配? 列值应该不确定吗?
预先感谢!
完整代码是:
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName('New booking');
var headers = sheet.getRange(1, 1,1,sheet.getLastColumn());
var lastRow = sheet.getLastRow();
var numRows= lastRow-1
var target = ss.getSheetByName('Test'); //temp redirect to test sheet
var lastDBRow =target.getLastRow(); //we want to append the data after this
var booking = getRowsData(sheet); // Get data to copy as array object
= ui.prompt(booking.length + " " + booking[0].length, ui.ButtonSet.OK);
// Returns 3 Undefined
var response = ui.prompt(numRows, ui.ButtonSet.OK);
// Returns 3
var range = target.getRange(lastDBRow+1,1,numRows); // Must match range size
range.setValues([booking]);
}
答案 0 :(得分:0)
在我看来,此范围内未定义列数: var range = target.getRange(lastDBRow + 1,1,numRows); //必须匹配范围大小 range.setValues([booking]); 在不打算使用调试的情况下,我无法确认我的想法,但是我看到您正在定义起始行,起始列和行数,但未定义列数。我不确定该错误消息是否是由该原因引起的,但似乎需要考虑。