DataRange

class pygsheets.DataRange(start=None, end=None, worksheet=None, name='', data=None, name_id=None, namedjson=None, protectedjson=None)[source]

DataRange specifies a range of cells in the sheet

Parameters:
  • start – top left cell address
  • end – bottom right cell address
  • worksheet – worksheet where this range belongs
  • name – name of the named range
  • data – data of the range in as row major matrix
  • name_id – id of named range
  • namedjson – json representing the NamedRange from api
name

name of the named range. setting a name will make this a range a named range setting this to empty string will delete the named range

name_id

if of the named range

protect_id

id of the protected range

protected

get/set the range as protected setting this to False will make this range unprotected

editors

Lists the editors of the protected range can also set a list of editors, take a tuple (‘users’ or ‘groups’, [<editors>])

requesting_user_can_edit

if the requesting user can edit protected range

start_addr

top-left address of the range

end_addr

bottom-right address of the range

range

Range in format A1:C5

worksheet

linked worksheet

cells

Get cells of this range

link the datarange so that all properties are synced right after setting them

Parameters:update – if the range should be synced to cloud on link

unlink the sheet so that all properties are not synced as it is changed

fetch(only_data=True)[source]

update the range data/properties from cloud

Warning

Currently only data is fetched not properties, so only_data wont work

Parameters:only_data – fetch only data
apply_format(cell)[source]

Change format of all cells in the range

Parameters:cell – a model :class: Cell whose format will be applied to all cells
update_values(values=None)[source]

Update the worksheet with values of the cells in this range

Parameters:values – values as matrix, which has same size as the range
sort(basecolumnindex=0, sortorder='ASCENDING')[source]

sort the values in the datarange

Parameters:
  • basecolumnindex – Index of the base column in which sorting is to be done (Integer). The index here is the index of the column in range (first columen is 0).
  • sortorder – either “ASCENDING” or “DESCENDING” (String)
update_named_range()[source]

update the named range properties

update_protected_range(fields='*')[source]

update the protected range properties