getRange¶
The getRange method calculates a report in the background and returns the values from a given range.
Syntax
getRange (range, asGrid, calculationId)
Arguments¶
range : string
(required)¶
The range to return. This can be any of the following:
- A1 reference
- R1C1 reference
- A1:B6 reference
- Named range
asGrid : boolean
¶
Specify whether the results are returned as a grid (as in Excel) or a key/value pair (cell reference and value).
Default value: false
calculationId : number
¶
If empty, this will return the values from the given range from the current report’s last calculation. If an id is specified, then it will use the results from the given calculation.
Return¶
asGrid=false return value (JSON):
{
"R1C1" : "A1",
"R1C2" : "B1",
"R2C1" : "A2",
"R2C2" : "B2"
}
asGrid=true return value (JSON):
{
0 : [ "A1", "B1" ],
1 : [ "A2", "B2" ]
}
Examples¶
//
// Example 1 - Retrieve range A1 from the current reports last calculation
//
var values1 = report.api.getRange("A1");
//
// Example 2 - Retrieve range A1:B3 from the current reports last calculation
//
var values2 = report.api.getRange("A1:B3");
//
// Example 3 - Retrieve range A1:B3 as a grid of data from the current reports last calculation
//
var values3 = report.api.getRange("A1:B3", true);
//
// Example 4 - Retrieve range A1:B3 as a grid of data from the calculationId 1232
//
var values4 = report.api.getRange("A1:B3", true, 1232);