import xlrd
import xlwt
from xlutils.copy import copy
import os
def xiugai(old_path,new_path,old_name,save_name,old_name1,new_name1,new_name2):
workbook = xlrd.open_workbook('\\'.join((old_path,old_name)),
formatting_info=1)
wb = copy(workbook)
worksheet = workbook.sheet_by_index(0)
for i in range(0, worksheet.nrows):
for j in range(0, worksheet.ncols):
if worksheet.cell_value(i, j) == old_name1:
font = xlwt.Font()
font.name = 'Times New Roman'
font.height = 220
style = xlwt.XFStyle()
style.font = font
wb.get_sheet(0).write(i, j, new_name1,style)
wb.get_sheet(0).write(i, j + 1, new_name2,style)
wb.save('\\'.join((new_path, save_name)))
def main():
xiugai(old_path,new_path,old_name,save_name,old_name1,new_name1,new_name2)