Openpyxl check for empty cell

前端 未结 4 1937
失恋的感觉
失恋的感觉 2020-12-15 18:49

openpyxl seems to be a great method for using Python to read Excel files, but I\'ve run into a constant problem. I need to detect whether a ce

4条回答
  •  情话喂你
    2020-12-15 19:05

    You can change the cell or cells you wish to validate Also you can code, for example:

    import openpyxl
    
    wb = openpyxl.load_workbook("file.xlsx")
    sheet = wb.get_sheet_by_name('Sheet1')
    
    if sheet.cell(row = 1, column=7).value == None:
        print("Blank") 
    else:
        print("No blank")
    

提交回复
热议问题