Logo GenPRES

GoogleSheets Module

Downloads a Google spreadsheet as an xlsx workbook, caches the workbook by spreadsheet id and returns the rows of a named sheet or an error.

Functions and values

Function or value Description

clearWorkbookCache ()

Full Usage: clearWorkbookCache ()

Parameters:
    () : unit

Forgets the workbooks read so far, so the next sheet read downloads the workbook again.

() : unit

createWorkbookUrl id

Full Usage: createWorkbookUrl id

Parameters:
    id : string

Returns: string

Creates the url that downloads the whole spreadsheet with the given id as an xlsx workbook.

id : string
Returns: string

downloadResult url

Full Usage: downloadResult url

Parameters:
    url : string

Returns: Async<Result<byte[], string>>

Downloads the bytes at the url. Returns an error when the response is not successful, for example 404 or 403, or when the network fails.

url : string
Returns: Async<Result<byte[], string>>

downloadWorkbook dataUrlId

Full Usage: downloadWorkbook dataUrlId

Parameters:
    dataUrlId : string

Returns: Async<Result<Map<string, Sheet>, string>>

Downloads and reads the workbook of the spreadsheet with the given id.

dataUrlId : string
Returns: Async<Result<Map<string, Sheet>, string>>

getRowsFromSheetSync dataUrlId name

Full Usage: getRowsFromSheetSync dataUrlId name

Parameters:
    dataUrlId : string
    name : string

Returns: Result<string array array, string>

Returns the rows of a sheet as text, the header row first, waiting for the result. Returns an error when the workbook cannot be loaded or has no sheet with that name. Writes an error to the console, and a warning when the sheet has hidden rows.

dataUrlId : string
name : string
Returns: Result<string array array, string>

getSheet dataUrlId name

Full Usage: getSheet dataUrlId name

Parameters:
    dataUrlId : string
    name : string

Returns: Async<Result<Sheet, string>>

Returns a sheet of the workbook of the spreadsheet with the given id. Returns an error when the workbook cannot be loaded or has no sheet with that name.

dataUrlId : string
name : string
Returns: Async<Result<Sheet, string>>

getWorkbookWith load dataUrlId

Full Usage: getWorkbookWith load dataUrlId

Parameters:
Returns: Async<Result<Map<string, Sheet>, string>>

Returns the workbook of the spreadsheet with the given id, loaded with load on the first call after a clear. A failed load is not kept, so the next call tries again.

load : string -> Async<Result<Map<string, Sheet>, string>>
dataUrlId : string
Returns: Async<Result<Map<string, Sheet>, string>>

hiddenRowsWarning name sheet

Full Usage: hiddenRowsWarning name sheet

Parameters:
    name : string
    sheet : Sheet

Returns: string option

Returns the warning for the sheet with the given name when it has hidden rows, or None when no row is hidden.

name : string
sheet : Sheet
Returns: string option

sharingHint

Full Usage: sharingHint

Returns: string

The hint for a spreadsheet that cannot be downloaded because it is not shared.

Returns: string

sheetRows rows

Full Usage: sheetRows rows

Parameters:
    rows : string array array

Returns: string array array

Removes every double quote from the cells of a sheet, as the CSV download did, because the sheet readers expect that.

rows : string array array
Returns: string array array

Type something to start searching.