On this page:
3.22.1 The Spreadsheet Type
Spreadsheet
3.22.2 The Worksheet Type
Worksheet
3.22.3 Spreadsheet Functions
create-spreadsheet
my-spreadsheet
load-spreadsheet
open-sheet
open-sheet-by-index
3.22.4 Spreadsheet Methods
.sheet-names
.sheet-by-name
.sheet-by-index

3.22 gdrive-sheets

Usage:
include gdrive-sheets
import gdrive-sheets as ...

3.22.1 The Spreadsheet Type

Spreadsheets represent a connection to a Google Sheets document. These spreadsheets are primarily used to create a Table, using the load-table: syntax and the .sheet-by-name method below. However, the spreadsheet values themselves can be useful to create or modify Google Sheets documents, as well.

3.22.2 The Worksheet Type

Worksheets represent individual worksheets within a Google Sheets document. Nothing can be done directly with worksheets in Pyret, except to load them into tables.

3.22.3 Spreadsheet Functions

Creates a new Google Sheets document with the given name, in the currently logged-in user’s Google Documents account. The newly created file will not yet have any worksheets in it.

Accesses a private Google Sheets file and produces a Spreadsheet. If the file is ever shared, change code that uses this function to instead call load-spreadsheet below.

Accesses a publicly shared Google sheets file and produces a Spreadsheet. This function is more commonly used than my-spreadsheet.

Accepts either the ID of a Google Sheets file, or the full URL. So, for example, these two uses access the same sheet:

animal-sheet1 = load-spreadsheet("https://docs.google.com/spreadsheets/d/1VeR2_bhpLvnRUZslmCAcSRKfZWs_5RNVujtZgEl6umA/") animal-sheet2 = load-spreadsheet("1VeR2_bhpLvnRUZslmCAcSRKfZWs_5RNVujtZgEl6umA")

open-sheet :: (
spreadsheet :: Spreadsheet,
name :: String,
skipHeaders :: Boolean
)
-> Worksheet

Obtains the Worksheet of the given name from the given Spreadsheet. Since worksheets commonly contain a header row with names describing the contents of each column, the last parameter tells Pyret whether to ignore the first row when extracted the data from the worksheet into a table. This function is a shortcut for using load-spreadsheet followed by the .sheet-by-name method. See Loading Tables for more information.

open-sheet-by-index :: (
spreadsheet :: Spreadsheet,
index :: Number,
skipHeaders :: Boolean
)
-> Worksheet

Much like open-sheet, except it selects the worksheet by its index within the file, with 0 being the first worksheet in the file. This function is a shortcut for using load-spreadsheet followed by the .sheet-by-index method.

3.22.4 Spreadsheet Methods

.sheet-names :: () -> List<String>

Returns the list of worksheet names in this Spreadsheet, in order from left to right. The names in this list can be used with .sheet-by-name, and the indices of names in this list can be used with .sheet-by-index.

.sheet-by-name :: (
name :: String,
skipHeaders :: Boolean
)
-> Worksheet

Obtains a Worksheet of the given name from the given worksheet. The skipHeaders argument specifies whether to ignore the first row of the sheet when extracting its contents as a table (i.e. to treat the first row as a header row rather than a data row).

.sheet-by-index :: (
index :: Number,
skipHeaders :: Boolean
)
-> Worksheet

Obtains a Worksheet of the given index (counting from 0) from the given worksheet. The skipHeaders argument specifies whether to ignore the first row of the sheet when extracting its contents as a table (i.e. to treat the first row as a header row rather than a data row).