查找表格对于值的位置并返回坐标

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','评价'))
上一篇:openpyxl模块以及练习题的讲解


下一篇:【加解密篇】Passware Kit Forensicz自定义解密类型教程