Skip to content

Commit

Permalink
added an update_cells example
Browse files Browse the repository at this point in the history
  • Loading branch information
burnash committed Mar 24, 2017
1 parent a9c5429 commit 217b430
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions gspread/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ def acell(self, label):
Example:
>>> wks.acell('A1') # this could be 'a1' as well
>>> worksheet.acell('A1')
<Cell R1C1 "I'm cell A1">
"""
Expand All @@ -389,7 +389,7 @@ def cell(self, row, col):
Example:
>>> wks.cell(1, 1)
>>> worksheet.cell(1, 1)
<Cell R1C1 "I'm cell A1">
"""
Expand All @@ -414,11 +414,11 @@ def range(self, name):
Example::
>>> # Using A1 notation
>>> wks.range('A1:B7')
>>> worksheet.range('A1:B7')
[<Cell R1C1 "42">, ...]
>>> # Same with numeric boundaries
>>> wks.range(1, 1, 7, 2)
>>> worksheet.range(1, 1, 7, 2)
[<Cell R1C1 "42">, ...]
"""
Expand Down Expand Up @@ -509,8 +509,7 @@ def update_acell(self, label, val):
Example:
>>> wks.update_acell('A1', '42') # this could be 'a1' as well
<Cell R1C1 "I'm cell A1">
worksheet.update_acell('A1', '42') # this could be 'a1' as well
"""
return self.update_cell(*(a1_to_rowcol(label)), val=val)
Expand All @@ -522,6 +521,10 @@ def update_cell(self, row, col, val):
:param col: Column number.
:param val: New value.
Example::
worksheet.update_cell(1, 1, '42')
"""
feed = self.client.get_cells_cell_id_feed(self,
self._cell_addr(row, col))
Expand Down Expand Up @@ -565,6 +568,17 @@ def update_cells(self, cell_list):
:param cell_list: List of a :class:`Cell` objects to update.
Example::
# Select a range
cell_list = worksheet.range('A1:C7')
for cell in cell_list:
cell.value = 'O_o'
# Update in batch
worksheet.update_cells(cell_list)
"""
feed = self._create_update_feed(cell_list)
self.client.post_cells(self, ElementTree.tostring(feed))
Expand Down

0 comments on commit 217b430

Please sign in to comment.