1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| import xlrd from xlutils.copy import copy
excel_path = r"D:\Users\zx\Desktop\information.xls"
rexcel = xlrd.open_workbook(excel_path, formatting_info=True) excel = copy(rexcel)
table = excel.get_sheet(0)
rows = rexcel.sheets()[0].nrows cols = rexcel.sheets()[0].ncols
style = xlwt.easyxf('pattern: pattern solid, fore_colour red')
table.write(row, col, tag, style)
excel.save(r"D:\Users\zx\Desktop\information.xls")
|