book = xlwt.Workbook(encoding='utf-8')
sheet_index = book.add_sheet('首页')
style = xlwt.XFStyle() # 创建一个样式对象,初始化样式
al = xlwt.Alignment()
al.horz = 0x02 # 设置水平居中
al.vert = 0x01 # 设置垂直居中
style.alignment = al
def add_sheet(defect_type, data_dict, i):
sheet_i = book.add_sheet(f'{i}')
line = 1
for k, v in data_dict.items():
sheet_i.write(line, 0,'数据', style)
line += 1
# 写入sheet超链接
def add_link(d, data_dict, sheet_num, line):
count_link = 'HYPERLINK("#%s!A1";"%s")' % (str('sheet名称'), str('名称'))
sheet_index.write(line, index, xlwt.Formula(count_link), style)