How to refresh a sheet's cell value in Google Apps Script

后端 未结 5 1267
囚心锁ツ
囚心锁ツ 2020-12-16 15:02

I\'m experimenting with Blockspring which provides a Google Sheets add-on which can, for example, run a function which returns data from a webservice e.g.

=B         


        
5条回答
  •  醉梦人生
    2020-12-16 15:19

    Refresh all table Its slow, but working!

    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheet = ss.getActiveSheet();
    var rangeData = sheet.getDataRange();
    var lastColumn = 38;
    var lastRow = 17;
    var searchRange = sheet.getRange(2,2, lastRow-1, lastColumn-1);
    
    function forceRefresh() {
      //Loop through each column and each row in the sheet.
      for(i = 1; i < lastColumn; i++){
        for (j = 1; j < lastRow ; j++){
          var cell = searchRange.getCell(j,i);
          var formula = cell.getFormula();
          var tempFormula = formula.replace("=", "?");
          cell.setFormula(tempFormula);
          SpreadsheetApp.flush();
          cell.setFormula(formula);
        };
      };
    };
    
    forceRefresh(); //call
    

提交回复
热议问题