我无法在测试功能的第27行找到错误:
var rowValues[column-2] = range.getValues();
我的代码:
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var lastRow = sheet.getLastRow();
var lastColumn = sheet.getLastColumn();
var now = new Date();
function test() {
for (row = 2; row < lastRow ; row++) {
range = sheet.getRange(row, 1, 1, 1);
dateAdd = range.getValues();
range = sheet.getRange(row, 5, 1, 1);
dateValidation = range.getValues();
timeDiff = Math.abs(now.getTime() - Date.parse(dateAdd));
diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
if (diffDays==1 && dateValidation==""){
for (column = 2; column < lastColumn ; column++) {
range = sheet.getRange(row, column, 1, 1);
rowValues[column-2] = range.getValues();
}
MailApp.sendEmail("xxxx@xxx.xxx","Subject %n","Description: \n %d \n %d \n %d",row,rowValues[0],rowValues[1],rowValues[3]);
}
}
}
答案 0 :(得分:4)
你已经使用了额外的var
,你不应该有一个 - 基本上你已经这样做了:
var array = [];
var array[0] = "foo";
你应该在哪里:
var array = [];
array[0] = "foo";
所以改变你的代码行:
var rowValues[column-2] = range.getValues();
到
rowValues[column-2] = range.getValues();
答案 1 :(得分:0)
尝试更新此行:
<强>这里:强>
var rowValues[column-2] = range.getValues();
要强>
rowValues[column-2] = [];
rowValues[column-2].push(range.getValues());
答案 2 :(得分:-1)
我找到了解决方案:
range = sheet.getRange(row, column, 1, 1);
rowValues.push(range.getValues());