Cell

class Cell

A str subclass — the cell’s current value is the string itself.

Obtain a Cell from get_cell() or by indexing a Row.

cell = await tab.get_cell("B2")
# or
cell = row[1]

print(cell)             # "hello"   (Cell is a str)
print(cell.label)       # "B"
print(cell.row_index)   # 2
print(cell.cell_index)  # 1  (0-based)
print(repr(cell))       # <Cell B2='hello'>

Attributes

Attribute

Type

Description

label

str

Column label, e.g. "A" or "AA".

row_index

int

1-based row number.

cell_index

int

0-based column index within its parent row.

tab

Tab

The Tab this cell belongs to.

row

Row | None

Parent Row, or None when fetched via get_cell().

Methods

async Cell.update(value, input_format='raw', render_format='formatted') Cell

Writes a new value and returns an updated Cell instance.

Parameters:
  • value – The new value to write.

  • input_format (str) – "raw" (default) or "user_entered" (evaluates formulas).

  • render_format (str) – "formatted" (default), "unformatted", or "formula".

Returns:

A new Cell with the updated value.

Return type:

Cell

Warning

Cell is immutable (it is a str). update() returns a new Cell — reassign the variable to keep the updated value.

cell = await cell.update("new value")
cell = await cell.update("=SUM(A1:A10)", input_format="user_entered")
async Cell.clear()

Clears the cell’s value.

await cell.clear()
async Cell.style(obj)

Applies formatting to this cell.

Parameters:

obj – A Style instance or a raw gspread_formatting.CellFormat.

await cell.style(Style(bold=True, text_color="#cc0000"))
async Cell.delete(shift='left')

Deletes the cell and shifts neighbouring cells.

Parameters:

shift (str) – "left" (default) shifts columns left; "up" shifts rows up.

await cell.delete()              # shift left (default)
await cell.delete(shift="up")    # shift up