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) 来源: oschina 链接: https://my.oschina.net/u/3766116/blog/4428039