How to use the pygsheets.cell.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 / worksheet.py View on Github external
max_cols = len(max(values, key=len))
            matrix = [list(x + [''] * (max_cols - len(x))) for x in values]
        else:
            matrix = 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 / chart.py View on Github external
def anchor_cell(self, new_anchor_cell):
        temp = self._anchor_cell
        try:
            if type(new_anchor_cell) is Cell:
                self._anchor_cell = (new_anchor_cell.row, new_anchor_cell.col)
                self._update_position()
            else:
                self._anchor_cell = format_addr(new_anchor_cell, 'tuple')
                self._update_position()
        except:
            self._anchor_cell = temp
github nithinmurali / pygsheets / pygsheets / worksheet.py View on Github external
matrix.extend([['']*max_cols]*(max_rows - len(matrix)))
        elif include_empty:
            max_cols = len(max(values, key=len))
            matrix = [list(x + [''] * (max_cols - len(x))) for x in values]
        else:
            matrix = 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 / worksheet.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 = format_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)