djechlin
djechlin

Reputation: 60748

Get column in Google Sheets App Scripts?

The Range class seems to view the table as an array of rows. It has the method getDataTable which returns an opaque DataTable. Lost in this seems to be how to select a column as an array. Even an Nx1 range, i.e. just a column, comes in the form [ [1], [2], [3], ...] instead of flat.

Is selecting a column really so suboptimal that it's that hard to do? I'm mostly hardcoding data so I can just rotate it if it is an optimization, just seems odd.

Upvotes: 0

Views: 4921

Answers (1)

Harold
Harold

Reputation: 3337

There is no specific method to select a column. You are always selecting a 2D table even if it has only one column.
The first dimension is for the row the second for the values in this row (aka the column values in this row). It's quite convenient to use. You can access whatever you want with the combination [row number][column number]. You'll also find a little everywhere methods to deal with it like transpose or get a column values of simply filter...
You just need to practice a little.

Upvotes: 1

Related Questions