Can't access sheet.rows

Issue #693 invalid
Krešimir Špes created an issue

I have a very weird problem that only happens one 1 of our machines, check the screenshot.

Basically, We can't access sheet.rows at all. Oddly enough, some other excel files work, but for this particular file (which I can't send due to NDA issues unfortunately) it doesn't work.

We're using python 2.7.10 on windows 10. We tried python 2.7.12 both 32bit and 64 bit, both installed via pip and from source code, no difference.

Any ideas what could be the problem? The weirdest thing is it works on all our machines, mac and windows alike, just not on one machine and I ran out of ideas as to what could be the cause..

Comments (4)

  1. CharlieC

    You're almost certainly using different versions of the library. In 2.4 rows and columns always return a generator. Previously you'd get a tuple of tuples in standard mode and a generator in read-only. Just materialise the generator to a tuple or a list and you'll be able to slice and index it.

  2. Steven Vereecken

    Which version of openpyxl are you using?

    There was a change (I believe in 2.4-a1) that made sheet.rows always return a generator (I think earlier it depended on how you opened the workbook, read-only or not or something). That means you cannot use sheet.rows[1] anymore (but you CAN use sheet[1] which does not first make a list of all rows in the sheet anymore as I think sheet.rows] used to do, you can of course also use list(sheet.rows))

    Anyway: this would suggest that your one "problem machine" has a more recent version of openpyxl?

  3. Krešimir Špes reporter

    unbelievable, you're right :/ I just checked, all machines have 2.3.5, while this one has 2.4.0. Sorry for wasting your time, we'll fix the code on our side now that we know the cause of the problem, thanks :)

  4. Log in to comment