MCPcopy
hub / github.com/burnash/gspread / update_cells

Method update_cells

gspread/worksheet.py:769–824  ·  view source on GitHub ↗

Updates many cells at once. :param list cell_list: List of :class:`gspread.cell.Cell` objects to update. :param value_input_option: (optional) How the input data should be interpreted. Possible values are: ``ValueInputOption.raw`` (default)

(
        self,
        cell_list: List[Cell],
        value_input_option: ValueInputOption = ValueInputOption.raw,
    )

Source from the content-addressed store, hash-verified

767 return data
768
769 def update_cells(
770 self,
771 cell_list: List[Cell],
772 value_input_option: ValueInputOption = ValueInputOption.raw,
773 ) -> Mapping[str, Any]:
774 """Updates many cells at once.
775
776 :param list cell_list: List of :class:`gspread.cell.Cell` objects to update.
777 :param value_input_option: (optional) How the input data should be
778 interpreted. Possible values are:
779
780 ``ValueInputOption.raw``
781 (default) The values the user has entered will not be parsed and will be
782 stored as-is.
783
784 ``ValueInputOption.user_entered``
785 The values will be parsed as if the user typed them into the
786 UI. Numbers will stay as numbers, but strings may be converted
787 to numbers, dates, etc. following the same rules that are
788 applied when entering text into a cell via
789 the Google Sheets UI.
790
791 See `ValueInputOption`_ in the Sheets API.
792
793 :type value_input_option: :namedtuple:`~gspread.utils.ValueInputOption`
794
795 .. _ValueInputOption: https://developers.google.com/sheets/api/reference/rest/v4/ValueInputOption
796
797 Example::
798
799 # Select a range
800 cell_list = worksheet.range('A1:C7')
801
802 for cell in cell_list:
803 cell.value = 'O_o'
804
805 # Update in batch
806 worksheet.update_cells(cell_list)
807 """
808 values_rect = cell_list_to_rect(cell_list)
809
810 start = rowcol_to_a1(
811 min(c.row for c in cell_list), min(c.col for c in cell_list)
812 )
813 end = rowcol_to_a1(max(c.row for c in cell_list), max(c.col for c in cell_list))
814
815 range_name = absolute_range_name(self.title, "{}:{}".format(start, end))
816
817 data = self.client.values_update(
818 self.spreadsheet_id,
819 range_name,
820 params={"valueInputOption": value_input_option},
821 body={"values": values_rect},
822 )
823
824 return data
825
826 def get(

Calls 5

cell_list_to_rectFunction · 0.85
rowcol_to_a1Function · 0.85
absolute_range_nameFunction · 0.85
formatMethod · 0.80
values_updateMethod · 0.45