xlrd xlwt xlutils
作者:互联网
常用方法
excelpath = r"../excel/接口.xls" # 打开excel workBook = xlrd.open_workbook(excelpath, formatting_info=True) # formatting_info 按原样式打开 sheets = workBook.sheet_names() # 获取所有的表名 workSheet = workBook.sheet_by_name('Sheet1') # 需要执行的sheet # 取数据 # cellData = workSheet.row_values(1) # 取一行 # cellData = workSheet.cell(1,6) # 取 第一行第6列 单元格 cellData = workSheet.cell(1, 6).value # 取 第一行第6列 单元格的值 # 获取excel行数 print(workSheet.nrows) # 1.拷贝 newWorkBook = copy.copy(workBook) # 这里workSheet还是workBook 要看下 # 2.取拷贝的excel的sheet---sheet 下标(默认从0开始) newSheet = newWorkBook.get_sheet(0) # 3. 写入数据--info--newSheet,write(行下标,列下标,内容) newSheet.write(case, 9, "pass") # 4.保存excel newWorkBook.save("../excel/result.xls")
标签:xlwt,cellData,xlutils,workSheet,excel,workBook,sheet,xlrd,newSheet 来源: https://www.cnblogs.com/TodayWind/p/14163449.html