get method

Future<ValueRange> get(
  1. String spreadsheetId,
  2. String range, {
  3. String? dateTimeRenderOption,
  4. String? majorDimension,
  5. String? valueRenderOption,
  6. String? $fields,
})

Returns a range of values from a spreadsheet.

The caller must specify the spreadsheet ID and a range.

Request parameters:

spreadsheetId - The ID of the spreadsheet to retrieve data from.

range - The [A1 notation or R1C1 notation](/sheets/api/guides/concepts#cell) of the range to retrieve values from.

dateTimeRenderOption - How dates, times, and durations should be represented in the output. This is ignored if value_render_option is FORMATTED_VALUE. The default dateTime render option is SERIAL_NUMBER. Possible string values are:

  • "SERIAL_NUMBER" : Instructs date, time, datetime, and duration fields to be output as doubles in "serial number" format, as popularized by Lotus 1-2-3. The whole number portion of the value (left of the decimal) counts the days since December 30th 1899. The fractional portion (right of the decimal) counts the time as a fraction of the day. For example, January 1st 1900 at noon would be 2.5, 2 because it's 2 days after December 30th 1899, and .5 because noon is half a day. February 1st 1900 at 3pm would be 33.625. This correctly treats the year 1900 as not a leap year.
  • "FORMATTED_STRING" : Instructs date, time, datetime, and duration fields to be output as strings in their given number format (which depends on the spreadsheet locale).

majorDimension - The major dimension that results should use. For example, if the spreadsheet data in Sheet1 is: A1=1,B1=2,A2=3,B2=4, then requesting range=Sheet1!A1:B2?majorDimension=ROWS returns [[1,2],[3,4]], whereas requesting range=Sheet1!A1:B2?majorDimension=COLUMNS returns [[1,3],[2,4]]. Possible string values are:

  • "DIMENSION_UNSPECIFIED" : The default value, do not use.
  • "ROWS" : Operates on the rows of a sheet.
  • "COLUMNS" : Operates on the columns of a sheet.

valueRenderOption - How values should be represented in the output. The default render option is FORMATTED_VALUE. Possible string values are:

  • "FORMATTED_VALUE" : Values will be calculated & formatted in the response according to the cell's formatting. Formatting is based on the spreadsheet's locale, not the requesting user's locale. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return "$1.23".
  • "UNFORMATTED_VALUE" : Values will be calculated, but not formatted in the reply. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return the number 1.23.
  • "FORMULA" : Values will not be calculated. The reply will include the formulas. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return "=A1". Sheets treats date and time values as decimal values. This lets you perform arithmetic on them in formulas. For more information on interpreting date and time values, see [About date & time values](https://developers.google.com/sheets/api/guides/formats#about_date_time_values).

$fields - Selector specifying which fields to include in a partial response.

Completes with a ValueRange.

Completes with a commons.ApiRequestError if the API endpoint returned an error.

If the used http.Client completes with an error when making a REST call, this method will complete with the same error.

Implementation

async.Future<ValueRange> get(
  core.String spreadsheetId,
  core.String range, {
  core.String? dateTimeRenderOption,
  core.String? majorDimension,
  core.String? valueRenderOption,
  core.String? $fields,
}) async {
  final queryParams_ = <core.String, core.List<core.String>>{
    if (dateTimeRenderOption != null)
      'dateTimeRenderOption': [dateTimeRenderOption],
    if (majorDimension != null) 'majorDimension': [majorDimension],
    if (valueRenderOption != null) 'valueRenderOption': [valueRenderOption],
    if ($fields != null) 'fields': [$fields],
  };

  final url_ = 'v4/spreadsheets/' +
      commons.escapeVariable('$spreadsheetId') +
      '/values/' +
      commons.escapeVariable('$range');

  final response_ = await _requester.request(
    url_,
    'GET',
    queryParams: queryParams_,
  );
  return ValueRange.fromJson(
      response_ as core.Map<core.String, core.dynamic>);
}