Home > Software design >  How can I read a certain row from a range to infinity on google apps script
How can I read a certain row from a range to infinity on google apps script

Time:10-05

I'm learning google apps script and making a sales project. I want to be able to read a certain column from a single cell into infinity (A1:infinity range for example). getRange functions only work if I give them an endpoint, how can I get around that?

CodePudding user response:

function readAllOfTheDataInAColumn() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName("Sheet1");
  const rg = sh.getRange("A1:A"   sh.getLastRow());
  const vs = rg.getValues();
}

CodePudding user response:

The Spreadsheet.getRange() and Sheet.getRange() methods work fine with open-ended ranges. You can get the values in column C2:C until the last row in the spreadsheet with something like this:

  const ss = SpreadsheetApp.getActive();
  const values = ss.getRange('Sheet1!C2:C').getValues();
  • Related