1.導(dǎo)入xlutils 的copy函數(shù)
from xlutils.copy import copy
2.讀取已有xlsx文件
file = os.getcwd() + '\xxx.xlsx'
workBook = xlrd.open_workbook(file)
3.復(fù)制該workBook 獲取xlwt可以讀取的table
table = copy(workBook)
4.通過workBook獲取sheet
sheet = workBook.get_sheet('sheet名')
5.通過sheet寫入數(shù)據(jù)
sheet.write('row', 'col', 'data')
6.保存表格
xlwt.save('xxx.xlsx')