1. Heikki Junes
  2. openpyxl
  3. Issues
Issue #5 new

Make worksheets numpy-style subscriptable [xpost from ericgazoni/openpyxl]

Jeffrey Tratner
created an issue

I'm interested in extending the Worksheet class to be subscriptable in a similar manner to numpy arrays. (using tuple syntax)


sheet1[10,15] --> returns (the value or cell object) for cell(col=10, row=15) sheet1[:,15] --> generator/iterator for row 15 (or possibly a slice) sheet1[10,:] --> generator/iterator for col 10 (or possibly a slice) sheet1[-1,:] --> generator/iterator for last column sheet1[:,-1] --> generator/iterator for last row sheet1[5:10, 15] --> returns generator/iterator for cells (5,15),(6,15),(7,15),(8,15),(9,15) [if 5:10 exists] -- same as slice notation I don't think this would be that difficult to implement, just using the same hooks, exceptions, etc as the cell(col=, row=) function and a generator function for the iterators.

I'm volunteering to do it and debug it. Just would like to know in advance that the main devs would be interested in such an addition (and that this hasn't come up and been rejected previously)

Posting it here too because I'm pretty sure it would be easy to write this so it works in Python 2.4+ and python 3.x