How to use the pygsheets.models.Cell 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
start = self.get_addr(start, 'tuple')
        if not include_empty:
            matrix = values
        else:
            max_cols = len(max(values, key=len))
            matrix = [list(x + ['']*(max_cols-len(x))) for x in values]

        if returnas == 'matrix':
            return matrix
        else:
            cells = []
            for k in range(len(matrix)):
                row = []
                for i in range(len(matrix[k])):
                    if majdim == 'COLUMNS':
                        row.append(Cell((start[0]+i, start[1]+k), matrix[k][i], self))
                    elif majdim == 'ROWS':
                        row.append(Cell((start[0]+k, start[1]+i), matrix[k][i], self))
                    else:
                        raise InvalidArgumentValue('majdim')

                cells.append(row)
            return cells
github nithinmurali / pygsheets / pygsheets / models.py View on Github external
matrix = values
        else:
            max_cols = len(max(values, key=len))
            matrix = [list(x + ['']*(max_cols-len(x))) for x in values]

        if returnas == 'matrix':
            return matrix
        else:
            cells = []
            for k in range(len(matrix)):
                row = []
                for i in range(len(matrix[k])):
                    if majdim == 'COLUMNS':
                        row.append(Cell((start[0]+i, start[1]+k), matrix[k][i], self))
                    elif majdim == 'ROWS':
                        row.append(Cell((start[0]+k, start[1]+i), matrix[k][i], self))
                    else:
                        raise InvalidArgumentValue('majdim')

                cells.append(row)
            return cells
github nithinmurali / pygsheets / pygsheets / models.py View on Github external
"""
        try:
            if type(addr) is str:
                val = self.client.get_range(self.spreadsheet.id, self._get_range(addr, addr), 'ROWS')[0][0]
            elif type(addr) is tuple:
                label = Worksheet.get_addr(addr, 'label')
                val = self.client.get_range(self.spreadsheet.id, self._get_range(label, label), 'ROWS')[0][0]
            else:
                raise CellNotFound
        except Exception as e:
            if str(e).find('exceeds grid limits') != -1:
                raise CellNotFound
            else:
                raise

        return Cell(addr, val, self)