Skip to content

getRanges

The getRanges method calculates a report in the background and returns the values from a given array of ranges.

Syntax

getRanges (ranges, calculationId)

Arguments

ranges : object (required)

This argument is an array of ranges to return. A range can be specified in any of the following formats:

  • A1 reference
  • R1C1 reference
  • A1:B6 reference
  • Named range

The format of this argument is a JavaScript string array:

 ["A1:B2", "G3:H7"]

calculationId : number

If empty, this will get the range values being asked for from the current report’s last calculation.

If an id is specified, then it will use the results from that calculation.

Return

The result of this will be a JSON object that has the following sample structure:

{ 
  "R1C1" : "123",
  "R1C2" : "Hello",
  "R2C1" : "$12,000.00",
}

Examples

//
// Example 1 - Retrieve ranges A1:B5 and the Named Range 'MyNamedRange' from current reports last calculation
//
var values1 = report.api.getRanges(["A1:B5", "MyNamedRange"]); 

//
// Example 2 - Calculate another report and then retrieve ranges A1:B5 and the Named Range 'MyNamedRange' from it
//
var calcId = report.api.getCalculationId("MyTestReport");
var values2 = report.api.getRanges(["A1:B5", "MyNamedRange"], calcId);
Back to top