DataRange(start=None, end=None, worksheet=None, name='', data=None, name_id=None, namedjson=None, protectedjson=None)¶
DataRange specifies a range of cells in the sheet
- 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 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
if of the named range
id of the protected range
get/set the range as protected setting this to False will make this range unprotected
Lists the editors of the protected range can also set a list of editors, take a tuple (‘users’ or ‘groups’, [<editors>]) can also set (‘domainUsersCanEdit’, Boolean)
if the requesting user can edit protected range
top-left address of the range
bottom-right address of the range
Range in format A1:C5
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
update the range data/properties from cloud
Currently only data is fetched not properties, so only_data wont work
Parameters: only_data – fetch only data
Change format of all cells in the range
- cell – a model :class: Cell whose format will be applied to all cells
- fields – comma seprated string of fields of cell to apply, refer to `google api docs <https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/cells#CellData> `
Update the worksheet with values of the cells in this range
Parameters: values – values as matrix, which has same size as the range
sort the values in the datarange
- 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)
Clear values in this datarange.
Parameters: fields – Comma separated list of field masks.
update the named range properties
update the protected range properties
update_borders(top=False, right=False, bottom=False, left=False, inner_horizontal=False, inner_vertical=False, style='NONE', width=1, red=0, green=0, blue=0)¶
update borders for range
- NB use style=’NONE’ to erase borders
- default color is black
- top – make a top border
- right – make a right border
- bottom – make a bottom border
- left – make a left border
- style – either ‘SOLID’, ‘DOTTED’, ‘DASHED’, ‘SOLID’, ‘SOLID_MEDIUM’, ‘SOLID_THICK’, ‘DOUBLE’ or ‘NONE’ (String).
- width – border width (depreciated) (Integer).
- red – 0-255 (Integer).
- green – 0-255 (Integer).
- blue – 0-255 (Integer).
Merge cells in range
! You can’t vertically merge cells that intersect an existing filter
Parameters: merge_type – either ‘MERGE_ALL’ ,’MERGE_COLUMNS’ ( = merge multiple rows (!) together to make column(s)) ,’MERGE_ROWS’ ( = merge multiple columns (!) together to make a row(s)) ,’NONE’ (unmerge)