getCalculatedRange¶
This function enables you to calculate a report in the background and return values from a given range.
Syntax
getCalculatedRange (reportName, range, asGrid, queryString, isPrivate, publisher)
Arguments¶
reportName : string
(required)¶
The name of the report to be calculated.
range : string
(required)¶
The range of the report to return. This can be any of the following:
- A1 reference
- R1C1 reference
- A1:B6 reference
- Named range
asGrid : boolean
¶
Whether the results should be returned as a grid (like in Excel), or in a key/value pair object of cell reference and value.
Default value: false
queryString : string
¶
Any additional query string arguments to be passed for the calculation of the report
Default value: ""
isPrivate : boolean
¶
Specify if the report is private.
Default value: false
publisher : string
¶
If it is a private report, specify the login id of the user that published it.
Default value: ""
Return¶
If the asGrid
option is not set or set to false, then the result set will be a JSON object in the following format
{
"R1C1" : "A1",
"R1C2" : "B1",
"R2C1" : "A2",
"R2C2" : "B2"
}
If the asGrid
option is set to true
, then the result set will be a JSON object in the following format:
{
0 : [ "A1", "B1" ],
1 : [ "A2", "B2" ]
}
Examples¶
The following code will call back to the server and calculate the named report and retrieve data from it, without ever rendering that report.
//
// Example 1 - Calculate the named public report and retrieve range A1
//
var values1 = report.api.getCalculatedRange("MyTestReport", "A1");
//
// Example 2 - Calculate the named public report and retrieve range A1:B3
//
var values2 = report.api.getCalculatedRange("MyTestReport", "A1:B3");
//
// Example 3 - Calculate the named public report and retrieve range A1:B3 as a grid of data
//
var values3 = report.api.getCalculatedRange("MyTestReport", "A1:B3", true);
//
// Example 4 - Calculate the named public report with some query string parameters and
// retrieve range A1:B3 as a grid of data.
//
var queryString = "[Date].[Date].%26[2]&R1C3=Yesterday"
var values4 = report.api.getCalculatedRange("MyTestReport", "A1:B3", true, queryString);
//
// Example 5 - Calculate the named private report and retrieve range A1:B3 as a grid of data
//
var values5 = report.api.getCalculatedRange("MyTestReport", "A1:B3", true, "", true, "sgibbs");