Kandan Siva
Kandan Siva

Reputation: 479

Error and Warning while fetching value from excel- openpyxl-PYTHON 3.6

I am trying to fetch value from cell using below code:

import openpyxl
wb=openpyxl.load_workbook(r'C:\Users\xyz\Desktop\xxx.xlsx')
sheet=wb.active
v = sheet.cell(9,9).value
print(v)

When I execute the code, I get the following error:

Warning (from warnings module):
  File "C:\Users\XYZ\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\worksheet\worksheet.py", line 303
    warn("Using a coordinate with ws.cell is deprecated. Use ws[coordinate] instead")
UserWarning: Using a coordinate with ws.cell is deprecated. Use ws[coordinate] instead

Traceback (most recent call last):
  File "C:/Users/XYZ/Desktop/test.py", line 14, in <module>
    v = sheet.cell(9,9).value
  File "C:\Users\XYZ\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\worksheet\worksheet.py", line 304, in cell
    row, column = coordinate_to_tuple(coordinate)

  File "C:\Users\XYZ\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\utils\cell.py", line 185, in coordinate_to_tuple
    col, row = coordinate_from_string(coordinate)

  File "C:\Users\XYZ\AppData\Local\Programs\Python\Python36-32\lib\site-packages\openpyxl\utils\cell.py", line 45, in coordinate_from_string
    match = COORD_RE.match(coord_string.upper())

AttributeError: 'int' object has no attribute 'upper'

Can anyone say what is wrong with my program.

Upvotes: 0

Views: 2280

Answers (1)

Mike M&#252;ller
Mike M&#252;ller

Reputation: 85482

You need to use keyword arguments:

v = sheet.cell(row=9, column=9).value

Upvotes: 5

Related Questions