范围的坐标超出了纸张的尺寸

时间:2017-04-30 18:30:03

标签: javascript google-apps-script google-sheets

我的问题与此直接相关:Google Apps Script - Spreadsheet - The coordinates of the target range are outside the dimensions of the sheet

我遇到了类似的问题,并且由于某种原因,不知道这是api的变化。

code.gs

    var ss = SpreadsheetApp.getActive();

dev.gs

function getValue() {
    var sheet = ss.getSheetByName('SheetName');
    Logger.log(sheet.getRange("B2").getValue()); // returns string value
    sheet.getRange("$H67").setValue('done'); // correctly sets value
}

print.gs

function printAdvLedger() { 
  var sm = {};
  prepAdvLedger(sm);
  advPrintSheets = ['AdvLedger_PRINT','PrintSheet','expenses'];

  advPrintSheets.forEach(function(printSheet){
    var sheet = ss.getSheetByName(printSheet); // returns printsheet
    sheet.getName(); // returns correct name of printSheet
    sheet.showSheet(); //execution error: The coordinates of the range are outside the dimensions of the sheet
  });

  function removeSheets(){
      var remove = [advPrintSheets[0]];
      if(budget == "Stateside"){
          remove.push(advPrintSheets[2])
      } 
      remove.forEach(function(removeSheet){
          var s = ss.getSheetByName(removeSheet); //returns correct sheet
          ss.deleteSheet(s); //execution error: The coordinates of the range are outside the dimensions of the sheet
      });
  }


  function prepAdvLedger(sm) {
      addAdvValues();

      function addAdvValues() {
          var operReimb = ss.getSheetByName("OperReimb"), //gets correct sheet
          purpose = sm.advance.purpose,
          amount = sm.advance.amount;
          Logger.log(amount); //logs number value
          Logger.log(purpose); //logs string value

          var name = operReimb.getName(); //returns correct sheet name

          var test = operReimb.getRange(2,2).getA1Notation(); //returns "B2"

          operReimb.getRange("$H67").setValue(purpose); //execution error: The coordinates of the range are outside the dimensions of the sheet
          operReimb.getRange("$U67").setValue(amount); //execution error: The coordinates of the range are outside the dimensions of the sheet
      }

  }
}

这之前有效,所以我不知道发生了什么变化。看起来像我遇到同样问题的多个地方。不知道这是否与嵌套函数有关。

0 个答案:

没有答案
相关问题