user1489765
user1489765

Reputation: 291

Is there a corresponding row 'header' method similar to this for column headers?

To get column headers, this worked (ColHeaderValues = sheeResponses.getDataRange().getValues().shift();).

Is there a similar method to get the row headers?

Do I have to create and populate a two dimensional array to do this?

What I am trying to accomplish is being able to reference a specific row number by looking up the value in column one.

Thanks, chuck

Upvotes: 0

Views: 60

Answers (2)

Joel
Joel

Reputation: 95

You can do

RowHeaderValues = sheetResponses.getDataRange().getValues().map(function(row){return row[0]});

Upvotes: 1

piscator
piscator

Reputation: 8699

You can use the find function of the 2D Arrays Library: https://sites.google.com/site/scriptsexamples/custom-methods/2d-arrays-library

find(Object[][] data, intColumnIndex, String value): int

var data = sheetResponses.getDataRange().getValues();
ArrayLib.find(data, 0, "valueInColumnOne");  

Upvotes: 1

Related Questions