Home > Net >  How can I get a RangeList's cell values?
How can I get a RangeList's cell values?

Time:08-04

I have a RangeList that contains a series of rows from which I want to draw data. For example, I might have the RangeList object defined:

const values = sheet.getRangeList(["1:1", "3:3", "5:5"])

The getValues() function doesn't work on the RangeList, is there a built in and faster way to get the values in Google App Scripts?

CodePudding user response:

Get Values

function lfunko() {
  const ss = SpreadsheetApp.getActive();
  const sh = ss.getSheetByName('Form')
  const values = sh.getRangeList(["1:1", "3:3", "5:5"]).getRanges().map(rg => rg.getValues().flat().filter(e => e)).join(',');
  Logger.log(values);
}
  • Related