Module: sheets/sheetOps.js

Handles talking to the Google Drive API GPL License Full Text

Author:
License:
  • GPL-3.0-or-later
Source:

Methods

(inner) autoInit()

just get the default service and use it

Source:

(async, inner) getSheetGridProperties(sheetInfo) → {Promise.<gridProperties>}

Get the grid properties which is an object with a rowCount and columnCount property.

Parameters:
Name Type Description
sheetInfo Object
Source:
Returns:
Type
Promise.<gridProperties>

(async, inner) getSheetProperties(sheetId)

Parameters:
Name Type Description
sheetId string
Source:

(async, inner) getSheetValues(sheetRange) → {Promise.<Array.<Array>>}

Get all the cells in the specified range. If a given row has no data in the final cells for a row, the array for that row is shortened. If a row has no data no array for that row is returned.

Parameters:
Name Type Description
sheetRange Object

range property should include name of tab Tab1!A2:C6

Source:
Returns:

an array of rows containing an array for each column of data (even if only one column).

Type
Promise.<Array.<Array>>
Example
getSheetValues({id:SOME_ID, range:TabName!A:I})

(inner) init(sheetService)

Set up this module with the object that allows access to the google sheet calls. Typically from the value returned by sheetService.init(). When testing a mocked object can be passed in. Only needs to be done once.

Parameters:
Name Type Description
sheetService Object

optional

Source:

(async, inner) setRangeData(sheetRangeData) → {Promise.<{config: {data: {values:Array.<Array>}}, data: {spreadsheetId:string, updatedRange:string, updatedRows:number, updatedColumns:number, updatedCells:number}}>}

Set a range of data in a target sheet with an array of arrays of data By default each inner array is a row in the sheet with an element for each column if a sparse array is sent the missing cells in the range are skipped (i.e. they aren't overwritten)

Parameters:
Name Type Description
sheetRangeData Object
Source:
Returns:

object with many props including config.data and data

{
  config: {
...
    data: {
      values: [[2D array of data sent]]
          }
...
    },
  data: {
    spreadsheetId,
    updatedRange,
    updatedRows,
    updatedColumns,
    updatedCells ,
  }
headers:{...}
status:number
statusText:string
}

these properties can be useful for testing

Type
Promise.<{config: {data: {values:Array.<Array>}}, data: {spreadsheetId:string, updatedRange:string, updatedRows:number, updatedColumns:number, updatedCells:number}}>
Example
setRangeData({id:"longgoogleid",range:"Sheet1!A1", data:[["R1C1","R1C2"],["R2C1","R2C2"]]})

(async, inner) setSheetCell(sheetRangeValue) → {Promise.<Object>}

Convenience function that will take a string or number primitive and wrap it into a 2D array to write to the spreadsheet.

Parameters:
Name Type Description
sheetRangeValue Object

where the range property should specify a single cell

Source:
Returns:

see setRangeData for details on returned Object

Type
Promise.<Object>
Example
setSheetCell({id:SHEET_ID, range:Tab!A1, value:"SomeValue"})

Type Definitions

gridProperties

Type:
  • object
Properties:
Name Type Description
isValid boolean
rowCount number
columnCount number
message string
Source: