Cell

class pygsheets.Cell(pos, val='', worksheet=None, cell_data=None)[source]

An instance of this class represents a single cell. A cell can be simple or complex. A complex cell will update all information on each value acess (more bandwidth). in a worksheet.

Parameters:
  • pos – position of the cell adress
  • val – value of the cell
  • worksheet – worksheet this cell belongs to
  • cell_data – Data about the cell in json, corresponding to cellData of sheets api
format = None

tuple specifying data format (format type, pattern) or just format

borders = None

border properties as json, see gsheets api docs

parse_value = None

if set false, value will be shown as it is set

row

Row number of the cell.

col

Column number of the cell.

label

Cell Label - Eg A1

value

get/set formatted value of the cell

value_unformatted

get unformatted value of the cell

formula

get/set formula if any of the cell

note

get/set note on the cell

color

get/set background color of the cell as tuple (red, green, blue, alpha)

simple

If this cell is simple. Simple cells will only fetch value, else it would fetch all the cell attributes

set_text_format(attribute, value)[source]

set the text format

Parameters:
  • attribute – one of the following “foregroundColor” “fontFamily”, “fontSize”, “bold”, “italic”, “strikethrough”, “underline”
  • value – corresponding value for the attribute
Returns:

class:Cell

set_text_rotation(attribute, value)[source]

set the text rotation

Parameters:
  • attribute – “angle” or “vertical”
  • value – corresponding value for the attribute. angle in (-90,90) for ‘angle’, boolean for ‘vertical’
Returns:

cell

set_text_alignment(alignment, direction=None)[source]

set text alignment in both the directions

param alignment:
 either LEFT, CENTER, RIGHT, TOP, MIDDLE, BOTTOM, None
param direction:
 Verical or horizondal; mandatory only if alignment is None

unlink the cell from worksheet. Unliked cells wont updated if any properties are changed. you have to lihnk again or call update to sync all changes values

link cell with a worksheet. Linked sheets will be updated instantanoulsy if any properties are changed These are most helpful if you are using a python terminal.

Parameters:
  • worksheet – the worksheet to link to
  • update – if the cell should be synces as after linking
Returns:

cell

neighbour(position)[source]

get a neighbouring cell of this cell

Parameters:position – a tuple of relative position of position as string as right, left, top, bottom or combinatoin
Returns:neighbouring cell
fetch(keep_simple=False)[source]

Update the value of the cell from sheet

update(force=False)[source]

update the sheet cell value with the attributes set

Parameters:force – update the cell even if its unlinked
get_json()[source]

get the json representation of the cell as per google api

set_json(cell_data)[source]

set the cell data from json obj of the cell as per google api

Parameters:cell_data – json data about cell