Adds multiple rows to the worksheet and populates them with values. Widens the worksheet if there are more values than columns. :param list values: List of rows each row is List of values for the new row. :param value_input_option: (optional) Determines how inpu
(
self,
values: Sequence[Sequence[Union[str, int, float]]],
value_input_option: ValueInputOption = ValueInputOption.raw,
insert_data_option: Optional[InsertDataOption] = None,
table_range: Optional[str] = None,
include_values_in_response: Optional[bool] = None,
)
| 1818 | ) |
| 1819 | |
| 1820 | def append_rows( |
| 1821 | self, |
| 1822 | values: Sequence[Sequence[Union[str, int, float]]], |
| 1823 | value_input_option: ValueInputOption = ValueInputOption.raw, |
| 1824 | insert_data_option: Optional[InsertDataOption] = None, |
| 1825 | table_range: Optional[str] = None, |
| 1826 | include_values_in_response: Optional[bool] = None, |
| 1827 | ) -> JSONResponse: |
| 1828 | """Adds multiple rows to the worksheet and populates them with values. |
| 1829 | |
| 1830 | Widens the worksheet if there are more values than columns. |
| 1831 | |
| 1832 | :param list values: List of rows each row is List of values for |
| 1833 | the new row. |
| 1834 | :param value_input_option: (optional) Determines how input data |
| 1835 | should be interpreted. Possible values are ``ValueInputOption.raw`` |
| 1836 | or ``ValueInputOption.user_entered``. |
| 1837 | See `ValueInputOption`_ in the Sheets API. |
| 1838 | :type value_input_option: :class:`~gspread.utils.ValueInputOption` |
| 1839 | :param str insert_data_option: (optional) Determines how the input data |
| 1840 | should be inserted. See `InsertDataOption`_ in the Sheets API |
| 1841 | reference. |
| 1842 | :param str table_range: (optional) The A1 notation of a range to search |
| 1843 | for a logical table of data. Values are appended after the last row |
| 1844 | of the table. Examples: ``A1`` or ``B2:D4`` |
| 1845 | :param bool include_values_in_response: (optional) Determines if the |
| 1846 | update response should include the values of the cells that were |
| 1847 | appended. By default, responses do not include the updated values. |
| 1848 | |
| 1849 | .. _ValueInputOption: https://developers.google.com/sheets/api/reference/rest/v4/ValueInputOption |
| 1850 | .. _InsertDataOption: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append#InsertDataOption |
| 1851 | """ |
| 1852 | range_label = absolute_range_name(self.title, table_range) |
| 1853 | |
| 1854 | params: ParamsType = { |
| 1855 | "valueInputOption": value_input_option, |
| 1856 | "insertDataOption": insert_data_option, |
| 1857 | "includeValuesInResponse": include_values_in_response, |
| 1858 | } |
| 1859 | |
| 1860 | body = {"values": values} |
| 1861 | |
| 1862 | res = self.client.values_append(self.spreadsheet_id, range_label, params, body) |
| 1863 | num_new_rows = len(values) |
| 1864 | self._properties["gridProperties"]["rowCount"] += num_new_rows |
| 1865 | return res |
| 1866 | |
| 1867 | def insert_row( |
| 1868 | self, |
no test coverage detected