cell.offset() is passing incorrect type as 'column' argument to worksheet.cell() in 2.2.0

Issue #437 resolved
Tony Cox created an issue

Code in older versions (cell.py):

def offset(self, row=0, column=0):
        offset_column = get_column_letter(column_index_from_string(
            self.column) + column)
        offset_row = self.row + row
        return self.parent.cell('%s%s' % (offset_column, offset_row))

This was passing in, for example, self.parent.cell('A1') for which the cell method would return the cell at A1.

Code in 2.2.0 (cell.py):

def offset(self, row=0, column=0):
        offset_column = get_column_letter(
            column_index_from_string(self.column) + column)
        offset_row = self.row + row
        return self.parent.cell(column=offset_column, row=offset_row)

This is now passing a value of, for example, 'A' in as the column index, which the worksheet.cell() expects to be an integer index.

I haven't had time to submit a test case for this, nor this issue yet, sorry, but both are just one line fixes.

Comments (4)

  1. Tony Cox reporter

    Here is the commit with the change. As self.parent.cell() is expecting it's column kwarg to be an integer, the change to this function needs to be:

    offset_column = self.column + column
  2. CharlieC

    This will be fixed in the next patch release but I'm wondering about the use case and whether it wouldn't be better to delegate the function to the worksheet. How are you using it?

  3. Log in to comment