Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sheet.getRange(1,1,1,12) what does the numbers in bracket specify?

Sheet.getRange(1,1,1,12)

I cannot understand the arguments 1,1,1,12 . What is this - the sheet id or row or what?

method getRange(row, column, optNumRows, optNumColumns)

here what does optNumRows and optNumColumns mean???

like image 652
Sneha Grewal Avatar asked Aug 14 '12 07:08

Sneha Grewal


2 Answers

Found these docu on the google docu pages:

  • row --- int --- top row of the range
  • column --- int--- leftmost column of the range
  • optNumRows --- int --- number of rows in the range.
  • optNumColumns --- int --- number of columns in the range

In your example, you would get (if you picked the 3rd row) "C3:O3", cause C --> O is 12 columns

edit

Using the example on the docu:

// The code below will get the number of columns for the range C2:G8
// in the active spreadsheet, which happens to be "4"
var count = SpreadsheetApp.getActiveSheet().getRange(2, 3, 6, 4).getNumColumns(); Browser.msgBox(count);

The values between brackets:
2: the starting row = 2
3: the starting col = C
6: the number of rows = 6 so from 2 to 8
4: the number of cols = 4 so from C to G

So you come to the range: C2:G8

like image 119
Terry Avatar answered Oct 05 '22 22:10

Terry


I know this is an older thread but I thought a graphic might help see this visually.

getRange(row, column, optNumRows, optNumColumns)

enter image description here

like image 24
Migpics Avatar answered Oct 06 '22 00:10

Migpics