How to use the pygsheets.models.Worksheet function in pygsheets

To help you get started, we’ve selected a few pygsheets examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nithinmurali / pygsheets / pygsheets / models.py View on Github external
def _fetch_sheets(self, jsonsheet=None):
        """update sheets list"""
        self._sheet_list = []
        if not jsonsheet:
            jsonsheet = self.client.open_by_key(self.id, returnas='json')
        for sheet in jsonsheet.get('sheets'):
            self._sheet_list.append(Worksheet(self, sheet))
github nithinmurali / pygsheets / pygsheets / models.py View on Github external
:param title: A title of a new worksheet.
        :param rows: Number of rows.
        :param cols: Number of columns.
        :param src_tuple: a tuple (spreadsheet id, worksheet id) specifying a worksheet to copy
        :param src_worksheet: source worksheet to copy values from

        :returns: a newly created :class:`worksheets `.
        """
        if self.batch_mode:
            raise RequestError("not supported in batch Mode")

        jsheet = dict()
        if src_tuple:
            jsheet['properties'] = self.client.sh_copy_worksheet(src_tuple[0], src_tuple[1], self.id)
            wks = Worksheet(self, jsheet)
            wks.title = title
        elif src_worksheet:
            if type(src_worksheet) != Worksheet:
                raise InvalidArgumentValue("src_worksheet")
            jsheet['properties'] = self.client.sh_copy_worksheet(src_worksheet.spreadsheet.id, src_worksheet.id, self.id)
            wks = Worksheet(self, jsheet)
            wks.title = title
        else:
            request = {"addSheet": {"properties": {'title': title, "gridProperties": {"rowCount": rows, "columnCount": cols}}}}
            result = self.client.sh_batch_update(self.id, request, 'replies/addSheet', False)
            jsheet['properties'] = result['replies'][0]['addSheet']['properties']
            wks = Worksheet(self, jsheet)
        self._sheet_list.append(wks)
        return wks
github nithinmurali / pygsheets / pygsheets / models.py View on Github external
:param cols: Number of columns.
        :param src_tuple: a tuple (spreadsheet id, worksheet id) specifying a worksheet to copy
        :param src_worksheet: source worksheet to copy values from

        :returns: a newly created :class:`worksheets `.
        """
        if self.batch_mode:
            raise RequestError("not supported in batch Mode")

        jsheet = dict()
        if src_tuple:
            jsheet['properties'] = self.client.sh_copy_worksheet(src_tuple[0], src_tuple[1], self.id)
            wks = Worksheet(self, jsheet)
            wks.title = title
        elif src_worksheet:
            if type(src_worksheet) != Worksheet:
                raise InvalidArgumentValue("src_worksheet")
            jsheet['properties'] = self.client.sh_copy_worksheet(src_worksheet.spreadsheet.id, src_worksheet.id, self.id)
            wks = Worksheet(self, jsheet)
            wks.title = title
        else:
            request = {"addSheet": {"properties": {'title': title, "gridProperties": {"rowCount": rows, "columnCount": cols}}}}
            result = self.client.sh_batch_update(self.id, request, 'replies/addSheet', False)
            jsheet['properties'] = result['replies'][0]['addSheet']['properties']
            wks = Worksheet(self, jsheet)
        self._sheet_list.append(wks)
        return wks
github nithinmurali / pygsheets / pygsheets / models.py View on Github external
jsheet = dict()
        if src_tuple:
            jsheet['properties'] = self.client.sh_copy_worksheet(src_tuple[0], src_tuple[1], self.id)
            wks = Worksheet(self, jsheet)
            wks.title = title
        elif src_worksheet:
            if type(src_worksheet) != Worksheet:
                raise InvalidArgumentValue("src_worksheet")
            jsheet['properties'] = self.client.sh_copy_worksheet(src_worksheet.spreadsheet.id, src_worksheet.id, self.id)
            wks = Worksheet(self, jsheet)
            wks.title = title
        else:
            request = {"addSheet": {"properties": {'title': title, "gridProperties": {"rowCount": rows, "columnCount": cols}}}}
            result = self.client.sh_batch_update(self.id, request, 'replies/addSheet', False)
            jsheet['properties'] = result['replies'][0]['addSheet']['properties']
            wks = Worksheet(self, jsheet)
        self._sheet_list.append(wks)
        return wks