import openpyxl #此函数用于查找对于值的位置并返回坐标 def recellweizhi(EXCELfile,findvalua): wb = openpyxl.load_workbook(EXCELfile,data_only=True) ws = wb.worksheets[0] for row in ws.rows: for v in row: if v.value ==findvalua: #print(v.coordinate) return v.coordinate print(recellweizhi('成绩表.xlsx','评价'))
#此函数用于查找对于值的位置并返回坐标索引值 def recellweizhi(EXCELfile,findvalua): wb = openpyxl.load_workbook(EXCELfile,data_only=True) ws = wb.worksheets[0] print(ws.cell(1,2).value) for row in ws.rows: for v in row: if v.value ==findvalua: #print(v.coordinate) re = [v.row,v.column] return re print(recellweizhi('成绩表.xlsx','评价'))