Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get value of a cell at position (row,column) with openpyxl?

I'm using openpyxl to get a value of a cell at a specific position defined by row and column number. Code from the documentation doesn't work.

Link to documentation: http://openpyxl.readthedocs.io/en/default/tutorial.html#accessing-one-cell.

Code from documentation:

for i in range(1,101): ... for j in range(1,101): ... ws.cell(row=i,column=j)

Code gives this Exception:

warn("Using a coordinate with ws.cell is deprecated. Use ws[coordinate] instead")

like image 425
Koroslak Avatar asked Dec 07 '17 16:12

Koroslak


Video Answer


1 Answers

Use openpyxl.cell.cell.Cell.value as,

wb = load_workbook(file_name, read_only=True)
test_sheet = wb["Test"]
row = 1
column = 1
print(test_sheet.cell(row, column).value)
like image 115
Koroslak Avatar answered Oct 17 '22 02:10

Koroslak