python 编辑表格文件

import xlrd,xlwt,xlutils

self.data = xlrd.open_workbook(file,formatting_info = True) #打开文件

sheet1 = self.data.sheet_by_name('功能用例模板')

writeOpenxlsx = copy(self.data) #复制excel内容和修改文件

#获取表格列内容

tag = sheet1.col_values(6)

#修改表格内容

writexlsxSheet = writeOpenxlsx.get_sheet('功能用例模板')

style1 = xlwt.easyxf(font:height 240, color-index red, bold on;align: wrap on, vert centre, horiz center;border: left thin,right thin,top thin,bottom thin) #表格格式:加上边框

writexlsxSheet.write(i,11,res,style1) #将结果写入第11列,表格格式为style1

#保存

writeOpenxlsx.save(file)

推荐:云浮市属于哪个省

猜你喜欢

转载自www.cnblogs.com/1994jinnan/p/13369391.html