python - xlrd: Select cell relative to another cell -
i'm wondering if there way select cell/cell range relative position of known cell? along lines of...
refcell = mysheet.cell(4, 4) desiredcell = refcell.relative_position(2, 1)
so desired cell select cell (6, 5).
i've looked through documentation (https://media.readthedocs.org/pdf/xlrd/latest/xlrd.pdf) can't find anything.
the reason want refcell
, surrounding desiredcells
stay together, position of block of cells change, breaking code. way can search worksheet single cell, , base rest of code on position.
# sentinel_rowx , sentinel_colx determined @ run-time ... (4, 4) in example. delta_rowx = 2 delta_colx = 1 base_rowx = sentinel_rowx + delta_rowx base_colx = sentinel_colx + delta_colx # application-specific code # e.g. operations on rectangle of 20 rows , 10 columns rowx in range(20): colx in range(10): do_something_with(sheet.cell(base_rowx+rowx, base_colx+colx))
is looking for?
Comments
Post a Comment