获取以下错误消息[TypeError:无法读取属性" 0.0"来自undefined。 (第39行,文件"代码")]尝试通过以下链接从Google工作表文件中的一个选项卡(POTemplate)执行get / setValue范围(POTemplate)到另一个选项卡(POHistory)时:{{3} }。我被要求发布我正在使用的GoogleSheet示例的截图图片,但不幸的是,声誉只有10个。
function submit() {
var app = SpreadsheetApp;
var orderSheet = app.getActiveSpreadsheet().getSheetByName("POTemplate");
var order1Row = 22, orderLastRow = orderSheet.getLastRow();
var tplRowsNum = orderLastRow - order1Row + 1;
var tplFCol = 1, tplLCol = 7;
var tplColsNum = tplLCol - tplFCol + 1;
var rangeData = orderSheet.getRange(22, 1, 2, 6).getValues();
var colIndexes = [2, 3, 4, 5, 6, 7 , 8];
var fData = filterByIndexes(rangeData, colIndexes);
var target = "POHistory";
var targetSheet = app.getActiveSpreadsheet().getSheetByName(target);
var tgtRow = targetSheet.getLastRow() + 1;
var tgtRowsNum = fData.length - tgtRow + 1;
var tgtCol = 1;
var tgtColsNum = fData[0].length - 1 + 1;
targetSheet.getRange(tgtRow, tgtCol, tgtRowsNum, tgtColsNum).setValues(fData);
}
function filterByIndexes(twoDArr, indexArr) {
var fData = [];
twoDArr = twoDArr.transpose();
for(var i=0; i<indexArr.length; i++) {
fData.push(twoDArr[indexArr[i]]);
}
return fData.transpose();
}
Array.prototype.transpose = function() {
var a = this,
w = a.length ? a.length : 0,
h = a[0] instanceof Array ? a[0].length : 0;
if (h === 0 || w === 0) {return [];}
var i, j, t = [];
for (i = 0; i < h; i++) {
t[i] = [];
for (j = 0; j < w; j++) {
t[i][j] = a[j][i];
}
}
return t;
}