The from openpyxl import load_workbook
The import OS
# the excel path
Cur_dir=OS. The path. The dirname (OS) path) abspath (__file__))
Excel_path=OS. Path. Join (cur_dir, "login_case. XLSX")
# this is open the excel
Wb=load_workbook (excel_path)
# through a form name, obtain the form
Sh=wb/' case1 '
# get header
Titles=[]
For the index in range (1, sh. Max_columu + 1) :
The index, value=https://bbs.csdn.net/topics/sh.cell (1) the value
Print (value)
Print:
D: \ \ python python. Exe D:/pythonwork/python_study/study/class13/read the test case data. Py
Traceback (the most recent call last) :
The File "D:/pythonwork/python_study/study/class13/read the test case data. Py", line 11, the in & lt; module>
Wb=load_workbook (excel_path)
File "D: \ python \ lib \ site - packages \ openpyxl \ reader \ excel py", line 315, in load_workbook
Reader. The read ()
File "D: \ python \ lib \ site - packages \ openpyxl \ reader \ excel py", line 276, in the read
Self. Read_workbook ()
File "D: \ python \ lib \ site - packages \ openpyxl \ reader \ excel py", line 148, in read_workbook
Wb_part=_find_workbook_part (self. Package)
File "D: \ python \ lib \ site - packages \ openpyxl \ reader \ excel py", line 113, in _find_workbook_part
Raise IOError (" File contains no valid workbook part ")
OSError: File contains no valid workbook part