SlySheets.sheets#

Google Sheets API and types. https://developers.google.com/sheets/api/guides/concepts

Functions

colToIndex(letters)

Convert A1 notation column letter(s) to it's corresponding index number.

indexToCol(index)

Convert a number to it's corresponding A1 notation column letter(s).

sheets_date(timestamp, tz)

Convert a DateTimeRenderOption.Lotus123 formatted datetime value to a python datetime object.

Classes

BatchEdit(page)

BatchEditOp(kind, content)

CellRange(a1)

0-indexed, inclusive, integer bounds for a range None means unbounded

DateTimeRenderOption(value)

How to format cells containing date/time/datetimes.

InsertDataOption(value)

Whether to insert new rows when updating a range, or overwrite any existing values.

MajorDimension(value)

Whether elements of the returned value array are columns or rows.

Page(page_meta, sheet)

Scope()

Spreadsheet(auth, sheet_id)

Class for handling sheets

ValueInputOption(value)

Whether to interpret the new value literally, or to parse the same as a user typing it in.

ValueRenderOption(value)

What format to return cells in, since formula and display content do not always match.

class SlySheets.sheets.Scope[source]#

Bases: object

SheetsReadOnly = 'https://www.googleapis.com/auth/spreadsheets.readonly'#
Sheets = 'https://www.googleapis.com/auth/spreadsheets'#
class SlySheets.sheets.ValueRenderOption(value)[source]#

Bases: Enum

What format to return cells in, since formula and display content do not always match. From https://developers.google.com/sheets/api/reference/rest/v4/ValueRenderOption.

FORMATTED = 'FORMATTED_VALUE'#
PLAIN = 'UNFORMATTED_VALUE'#
FORMULA = 'FORMULA'#
class SlySheets.sheets.ValueInputOption(value)[source]#

Bases: Enum

Whether to interpret the new value literally, or to parse the same as a user typing it in. From https://developers.google.com/sheets/api/reference/rest/v4/ValueInputOption.

RAW = 'RAW'#
USER = 'USER_ENTERED'#
class SlySheets.sheets.InsertDataOption(value)[source]#

Bases: Enum

Whether to insert new rows when updating a range, or overwrite any existing values. From https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append#InsertDataOption.

OVERWRITE = 'OVERWRITE'#
INSERT = 'INSERT_ROWS'#
class SlySheets.sheets.MajorDimension(value)[source]#

Bases: Enum

Whether elements of the returned value array are columns or rows. From https://developers.google.com/sheets/api/reference/rest/v4/Dimension.

ROW = 'ROWS'#
COLUMN = 'COLUMNS'#
class SlySheets.sheets.DateTimeRenderOption(value)[source]#

Bases: Enum

How to format cells containing date/time/datetimes. From https://developers.google.com/sheets/api/reference/rest/v4/DateTimeRenderOption.

Lotus123 = 'SERIAL_NUMBER'#
Formatted = 'FORMATTED_STRING'#
SlySheets.sheets.indexToCol(index)[source]#

Convert a number to it’s corresponding A1 notation column letter(s).

Parameters:

index (int) –

Return type:

str

SlySheets.sheets.colToIndex(letters)[source]#

Convert A1 notation column letter(s) to it’s corresponding index number.

Parameters:

letters (str) –

Return type:

int

class SlySheets.sheets.CellRange(a1)[source]#

Bases: object

0-indexed, inclusive, integer bounds for a range None means unbounded

Initialise from A1 notation.

Parameters:

a1 (str) –

page: str | None#
from_row: int#
to_row: int | None#
from_col: int#
to_col: int#
shape()[source]#

Return the number of rows and columns in the range.

SlySheets.sheets.sheets_date(timestamp, tz)[source]#

Convert a DateTimeRenderOption.Lotus123 formatted datetime value to a python datetime object.

Parameters:
Return type:

datetime

class SlySheets.sheets.Page(page_meta, sheet)[source]#

Bases: object

Parameters:
id: int#
title: str#
n_columns: int#
await grid_row_count()[source]#

Fetch the number of rows in the page grid. May include empty cells.

await range(a1)[source]#
Parameters:

a1 (str) –

await delete_range(a1)[source]#
Parameters:

a1 (str) –

await set_range(a1, values)[source]#
Parameters:
await set_cell(a1, value)[source]#
Parameters:
await rows(start, end, n_cols=None)[source]#

Get the content of a range of rows, inclusive, zero-indexed

Parameters:
  • start (int) –

  • end (int) –

  • n_cols (int | None) –

await row(index, n_cols=None)[source]#

Get the content of a single row, zero-indexed

Parameters:
  • index (int) –

  • n_cols (int | None) –

await cell(a1)[source]#

Get the content of a single cell

Parameters:

a1 (str) –

await date_at_cell(a1)[source]#

Get the date at a cell

Parameters:

a1 (str) –

Return type:

datetime

await column(index)[source]#
Parameters:

index (int) –

await column_named(name)[source]#
Parameters:

name (str) –

await rows_dicts(start, end)[source]#
Parameters:
  • start (int) –

  • end (int) –

await extend(values, search_='A1')[source]#
Parameters:
await extend_dicts(values, search_='A1')[source]#
Parameters:
await append(row, search_='A1')[source]#
Parameters:
await append_dict(obj, search_='A1')[source]#
Parameters:
batch()[source]#
await tz()[source]#

Get the default timezone of the spreadsheet the page is in

class SlySheets.sheets.BatchEditOp(kind: str, content: dict)[source]#

Bases: object

Parameters:
kind: str#
content: dict[str, Any]#
class SlySheets.sheets.BatchEdit(page)[source]#

Bases: object

Parameters:

page (Page) –

set_range(a1, values)[source]#
Parameters:
class SlySheets.sheets.Spreadsheet(auth, sheet_id)[source]#

Bases: WebAPI

Class for handling sheets

Parameters:
  • auth (OAuth2) –

  • sheet_id (str) –

base_url: str = 'https://sheets.googleapis.com/v4/spreadsheets'#
id: str#

Hyperlink to the spreadsheet

await title()[source]#

Title of the spreadsheet

await tz()[source]#

Default timezone of the spreadsheet

await pages()[source]#

Get a Page for each page in the spreadhsheet

Return type:

list[SlySheets.sheets.Page]

await page(title)[source]#

Get a Page by title

Parameters:

title (str) –

await range(a1)[source]#
Parameters:

a1 (str | CellRange) –

Return type:

list[list[int | str | float | None]]

await delete_range(a1)[source]#
Parameters:

a1 (str | CellRange) –

await cell(a1)[source]#
Parameters:

a1 (str) –

Return type:

int | str | float | None

await set_range(a1, values)[source]#
Parameters:
await set_cell(a1, value)[source]#
Parameters:
await date_at_cell(a1)[source]#
Parameters:

a1 (str) –

Return type:

datetime

await extend(values, page, search_='A1')[source]#
Parameters: