0

I'm trying to find out how to get data from a single row in a spreadsheet using Google Apps Script.

I've managed to get data from a single column in a spreadsheet using Google Apps Script but when I adjust the range for a single row with multiple columns it comes back different.

Basically I think it is coming to me as a comma-separated list but I need it to be in an array-like what I'm getting when I use the code below.

Here is the code I am using to get data from a single column

var temp = activeSheet.getRange("A1:A6").getValues();
Aaron D.
  • 1
  • 3
  • They're always arrays. They're not a comma separated list. If the above linked questions don't answer your question satisfactorily, [edit] your question to show why it's different. – TheMaster Sep 01 '20 at 03:16

1 Answers1

0

One way to get the values from a single row is to use

var values = SpreadsheetApp.getActiveSheet().getRange('1:1').getValues()[0];

The above code will return all the values for the first row from the active sheet.

NOTES:

getValues() return an Array of Arrays, where each inner Array corresponds to each range row. The inner array elements are ordered according to the range columns.

Resources

Rubén
  • 34,714
  • 9
  • 70
  • 166