google app脚本:记录activeRange实时监控

时间:2018-12-01 12:00:00

标签: range sleep monitor gas

有我的代码。我尝试使用sleep方法更新范围(activeRange)。范围未更新。你有什么主意吗 ? 谢谢

function onOpen() {
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
  .createMenu('Custom Menu')
  .addItem('Show sidebar', 'showSidebar')
  .addToUi();
}

function showSidebar() {
  var html = HtmlService.createHtmlOutputFromFile('Page')
  .setTitle('My custom sidebar')
  .setWidth(300);
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
  .showSidebar(html);
}

function getActiveRange(){


for (i=1; i<50; i++){

Utilities.sleep(100);
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Feuille 1');
var range = sheet.getActiveRange().getA1Notation();
SpreadsheetApp.getActiveSheet().getRange(i,1).setValue(range);
SpreadsheetApp.flush();

}   

}

0 个答案:

没有答案