Returns a worksheet with specified `index`. :param index: An index of a worksheet. Indexes start from zero. :type index: int :returns: an instance of :class:`gspread.worksheet.Worksheet`. :raises: :class:`~gspread.exceptions.WorksheetNotFound`: if can't
(self, index: int)
| 230 | return self.client.fetch_sheet_metadata(self.id, params=params) |
| 231 | |
| 232 | def get_worksheet(self, index: int) -> Worksheet: |
| 233 | """Returns a worksheet with specified `index`. |
| 234 | |
| 235 | :param index: An index of a worksheet. Indexes start from zero. |
| 236 | :type index: int |
| 237 | |
| 238 | :returns: an instance of :class:`gspread.worksheet.Worksheet`. |
| 239 | |
| 240 | :raises: |
| 241 | :class:`~gspread.exceptions.WorksheetNotFound`: if can't find the worksheet |
| 242 | |
| 243 | Example. To get third worksheet of a spreadsheet: |
| 244 | |
| 245 | >>> sht = client.open('My fancy spreadsheet') |
| 246 | >>> worksheet = sht.get_worksheet(2) |
| 247 | """ |
| 248 | sheet_data = self.fetch_sheet_metadata() |
| 249 | |
| 250 | try: |
| 251 | properties = sheet_data["sheets"][index]["properties"] |
| 252 | return Worksheet(self, properties, self.id, self.client) |
| 253 | except (KeyError, IndexError): |
| 254 | raise WorksheetNotFound("index {} not found".format(index)) |
| 255 | |
| 256 | def get_worksheet_by_id(self, id: Union[str, int]) -> Worksheet: |
| 257 | """Returns a worksheet with specified `worksheet id`. |