简单看下一下代码:
#Excel文件读取函数定义
def Excel_Read(filename, sheetnum):
#Excel文件读取路径
case_dir = UrlConfig.ExportDataUrl + filename + '.xls'
#打开Excel文件
open_wb = xlrd.open_workbook(case_dir)
#获取Excel文件第N个sheet
sheet = open_wb.sheets()[sheetnum]
#获取Excel文件sheet名称
sheetname = open_wb.sheet_names()[sheetnum]
#sheet行列定义
nor = sheet.nrows
nol = sheet.ncols
return nor, sheet, sheetname
#Excel文件写入函数定义
def Excel_Write_Data(worksheet, workbook, sheetname, nor, id, title, method, url, data, case_code, result, i):
alignment = xlwt.Alignment()
alignment.horz = alignment.HORZ_CENTER
alignment.vert = alignment.VERT_CENTER
style = xlwt.XFStyle()
style.alignment = alignment
nowl = 2
norl = nor
i = i + 1
#合并第1行8列,并写入'测试报告(StoreManage)'
worksheet.w