Resizes the worksheet. Specify one of ``rows`` or ``cols``. :param int rows: (optional) New number of rows. :param int cols: (optional) New number columns.
(
self, rows: Optional[int] = None, cols: Optional[int] = None
)
| 1486 | return self.batch_format(formats) |
| 1487 | |
| 1488 | def resize( |
| 1489 | self, rows: Optional[int] = None, cols: Optional[int] = None |
| 1490 | ) -> JSONResponse: |
| 1491 | """Resizes the worksheet. Specify one of ``rows`` or ``cols``. |
| 1492 | |
| 1493 | :param int rows: (optional) New number of rows. |
| 1494 | :param int cols: (optional) New number columns. |
| 1495 | """ |
| 1496 | grid_properties = {} |
| 1497 | |
| 1498 | if rows is not None: |
| 1499 | grid_properties["rowCount"] = rows |
| 1500 | |
| 1501 | if cols is not None: |
| 1502 | grid_properties["columnCount"] = cols |
| 1503 | |
| 1504 | if not grid_properties: |
| 1505 | raise TypeError("Either 'rows' or 'cols' should be specified.") |
| 1506 | |
| 1507 | fields = ",".join("gridProperties/%s" % p for p in grid_properties.keys()) |
| 1508 | |
| 1509 | body = { |
| 1510 | "requests": [ |
| 1511 | { |
| 1512 | "updateSheetProperties": { |
| 1513 | "properties": { |
| 1514 | "sheetId": self.id, |
| 1515 | "gridProperties": grid_properties, |
| 1516 | }, |
| 1517 | "fields": fields, |
| 1518 | } |
| 1519 | } |
| 1520 | ] |
| 1521 | } |
| 1522 | |
| 1523 | res = self.client.batch_update(self.spreadsheet_id, body) |
| 1524 | if rows is not None: |
| 1525 | self._properties["gridProperties"]["rowCount"] = rows |
| 1526 | if cols is not None: |
| 1527 | self._properties["gridProperties"]["columnCount"] = cols |
| 1528 | return res |
| 1529 | |
| 1530 | def sort( |
| 1531 | self, *specs: Tuple[int, Literal["asc", "des"]], range: Optional[str] = None |