1

I am trying to work with openpyxl following a Programming with Mosh Python course. I can't open cells when using the .cell method. This happens for me when calling the cell by string as well. Any help welcome. Thank you.

Here's my code:

import openpyxl as xl
wb = xl.load_workbook('transactions.xlsx')
sheet = wb['Sheet1']
cell = sheet.cell(1, 1)
print(cell)
# prints <Cell 'Sheet'.A1> without actual cell information 
DapperDuck
  • 2,728
  • 1
  • 9
  • 21
Jake Snell
  • 13
  • 4
  • Does this answer your question? [How to access the real value of a cell using the openpyxl module for python](https://stackoverflow.com/questions/22613272/how-to-access-the-real-value-of-a-cell-using-the-openpyxl-module-for-python) – Gino Mempin Jan 02 '21 at 05:21

1 Answers1

0

Use .value to get information from a cell. Here is the corrected code:

import openpyxl as xl
wb = xl.load_workbook('transactions.xlsx')
sheet = wb['Sheet1']
cell = sheet.cell(1, 1)
print(cell.value)
DapperDuck
  • 2,728
  • 1
  • 9
  • 21