python library to read Excel data openpyxl

'' ' 
Openpyxl .xlsx formats only support

' ''
from openpyxl Import load_workbook
class do_excle:
. #. 1 # open Excle
# load_workbook WB = ( "testdata.xlsx")
. # 2 # target specific form Sheet
# Sheet WB = [ " sheet1 "] # pass form name, form object returns a
# 3 # targeting cell, the value of the ranks.
# sheet.cell value = (. 1,. 1) .Value
# Print (" maximum row:. {} "format (sheet . MAX_ROW))
# Print ( "maximum line: {}." the format (sheet.max_column))
# Print ( "get the result:", value)

DEF get_Data (Self):
WB = load_workbook (self.file_name)
Sheet WB = [self.sheet.name]
TEST_DATA = []
# read a tables all rows Excel, 1-4 data column
for i in range (1, sheet .max_row+1):
sub_data = {}
sub_data['method'] =sheet.cell(i, 1).value
sub_data['url'] = sheet.cell(i, 2).value
sub_data['data'] = sheet.cell(i, 3).value
sub_data['expected'] = sheet.cell(i, 4).value
test_data.append(sub_data)

return test_data

Guess you like

Origin www.cnblogs.com/tracker001/p/11352938.html