Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script 要在Google应用程序脚本中偏移到下一页的时间戳数据_Google Apps Script_Google Sheets - Fatal编程技术网

Google apps script 要在Google应用程序脚本中偏移到下一页的时间戳数据

Google apps script 要在Google应用程序脚本中偏移到下一页的时间戳数据,google-apps-script,google-sheets,Google Apps Script,Google Sheets,我希望时间戳数据显示在另一张工作表中,而不是显示在单元格中。我不想使用.tocopy方法,因为数据可能会在活动工作表中被删除(存档);从工作表中删除数据时,时间戳数据应保留在下一个工作表中 下面的代码片段: function onEdit() { var s = SpreadsheetApp.getActiveSheet(); if( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet var

我希望时间戳数据显示在另一张工作表中,而不是显示在单元格中。我不想使用.tocopy方法,因为数据可能会在活动工作表中被删除(存档);从工作表中删除数据时,时间戳数据应保留在下一个工作表中

下面的代码片段:

function onEdit() {
  var s = SpreadsheetApp.getActiveSheet();
  if( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet
    var r = s.getActiveCell();
    if( r.getColumn() == 1 ) { //checks the column
      var nextCell = r.offset(0, 1);
      if( nextCell.getValue() === '' ) //is empty?
        nextCell.setValue(new Date());
    }
  }
}

如果知道要输入日期的工作表的名称,只需获取该工作表的引用,然后设置值

var sheetToWriteTo = s.getSheetByName('sheetName');
sheetToWriteTo.getRange(put range here).setValue(new Date());