Reputation: 1344
I have this code:
for row in ws.iter_rows('A1:C2'):
for cell in row:
print cell
I want to print out the actual value of cell, in other words, what is actually the contents of that cell. I know this is easy, but I can't find it anywhere. I tried doing ws[cell], but it brought an error.
Here's what's given now:
<openpyxl.cell.read_only.ReadOnlyCell object at 0x0296EFC0>
<openpyxl.cell.read_only.ReadOnlyCell object at 0x0295F6F0>
<openpyxl.cell.read_only.ReadOnlyCell object at 0x0295F6F0>
<openpyxl.cell.read_only.ReadOnlyCell object at 0x0297E5D0>
<openpyxl.cell.read_only.ReadOnlyCell object at 0x0297E5A0>
<openpyxl.cell.read_only.ReadOnlyCell object at 0x0295F6F0>
Upvotes: 1
Views: 2871
Reputation: 3891
To get the value of a cell in openpyxl
you need to use the cell.value
method.
In your code:
for row in ws.iter_rows('A1:C2'):
for cell in row:
print cell.value
Upvotes: 3