Esempio n. 1
0
    def freeze(self, rows=None, cols=None, sheet=None):
        """
        Freeze rows and/or columns for the open worksheet.

        Parameters
        ----------
        rows : int
            number of rows to freeze, use 0 to 'unfreeze' (default None)
        cols : int
            number of columns to freeze, use 0 to 'unfreeze' (default None)
        sheet : str,int,Worksheet
            optional, if you want to open or create a
            different sheet before freezing,
            see :meth:`open_sheet <gspread_pandas.spread.Spread.open_sheet>`
            (default None)

        Returns
        -------
        None
        """
        self._ensure_sheet(sheet)

        if rows is None and cols is None:
            return

        self.spread.batch_update(
            {"requests": create_frozen_request(self.sheet.id, rows, cols)})

        self.refresh_spread_metadata()
Esempio n. 2
0
    def freeze(self, rows=None, cols=None, sheet=None):
        """
        Freeze rows and/or columns for the open worksheet.

        :param int rows: the DataFrame to save
        :param int cols: whether to include the index in worksheet (default True)
        :param str,int,Worksheet sheet: optional, if you want to open or create a different sheet
            before freezing,
            see :meth:`open_sheet <gspread_pandas.client.Spread.open_sheet>` (default None)
        """
        if sheet:
            self.open_sheet(sheet, create=True)

        if not self.sheet:
            raise Exception("No open worksheet")

        if rows is None and cols is None:
            return

        sheet_id = self._sheet_metadata['properties']['sheetId']

        req = {'requests': [create_frozen_request(sheet_id, rows, cols)]}

        self.clientv4.batchUpdate(spreadsheetId=self.spread.id, body=req)\
                     .execute()
Esempio n. 3
0
    def freeze(self, rows=None, cols=None, sheet=None):
        """Freeze rows and/or columns for the open worksheet.

        Parameters
        ----------
        rows : int
            the DataFrame to save (Default value = None)
        cols : int
            whether to include the index in worksheet (default True)
        sheet : str,int,Worksheet
            optional, if you want to open or create a
            different sheet before freezing,
            see :meth:`open_sheet <gspread_pandas.client.Spread.open_sheet>`
            (default None)

        Returns
        -------
        None

        """
        if sheet:
            self.open_sheet(sheet, create=True)

        if not self.sheet:
            raise NoWorksheetException("No open worksheet")

        if rows is None and cols is None:
            return

        self.spread.batch_update(
            {"requests": create_frozen_request(self.sheet.id, rows, cols)})

        self.refresh_spread_metadata()
Esempio n. 4
0
def test_create_frozen_request():
    ret = util.create_frozen_request("", 1, 2)
    assert isinstance(ret, dict)