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)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章