我正在使用openpyxl获取由行和列号定义的特定位置的单元格值.
文档中的代码不起作用.
链接到文档:
http://openpyxl.readthedocs.io/en/default/tutorial.html#accessing-one-cell.
来自文档的代码:
for i in range(1,101):
… for j in range(1,101):
… ws.cell(row=i,column=j)
代码给出此异常:
warn(“Using a coordinate with ws.cell is deprecated. Use ws[coordinate] instead”)
解决方法:
from openpyxl import load_workbook
wb = load_workbook(file_name, read_only=True)
test_sheet = wb["Test"]
print(test_sheet.cell(None, 1, 1).value)
使用’.cell(self,ordinated = None,row = None,column = None,value = None):’方法访问单元格时,需要添加’None’.