wb = Workbook()
ws = wb.create_sheet('月度排名匯總', 0)
# 合并單元格
ws.merge_cells('b2:b3')
ws.merge_cells('c2:c3')
ws.merge_cells('d2:d3')
ws.merge_cells('e2:g2')
ws.merge_cells('h3:j2')
# 設(shè)置單元格文本內(nèi)容
ws['b2'].value = '負(fù)責(zé)人'
ws['c2'].value = '部門/小組'
ws['d2'].value = '負(fù)責(zé)產(chǎn)品總量'
ws['e2'].value = '與初始排名比較'
ws['h3'].value = '與月初排名比較'
ws['e3'].value = ws['h4'].value = '排名提升'
ws['f3'].value = ws['i3'].value = '排名不變'
ws['g3'].value = ws['j3'].value = '排名下滑'
# 創(chuàng)建單元格樣式對(duì)象
headerCellStyle = NamedStyle(name = 'headerCellStyle')
headerCellStyle.alignment = Alignment(horizontal = 'center', vertical = 'center') # 水平垂直居中
border = Side(border_style = 'thin', color = '000000') # 線框樣式
headerCellStyle.border = Border(left = border, top = border, right = border, bottom = border) # 設(shè)置單元格邊框樣式
# 設(shè)置表格樣式
for row in ws['b2:j30']:
for cell in row:
cell.style = headerCellStyle
# 數(shù)據(jù)寫入
for index, item in enumerate(data, 4):
ws.cell(row = index, column = 2, value = item.get('name'))
ws.cell(row = index, column = 3, value = item.get('group_name'))
ws.cell(row = index, column = 4, value = item.get('total'))
ws.cell(row = index, column = 5, value = item.get('initial').get('up'))
ws.cell(row = index, column = 6, value = item.get('initial').get('normal'))
ws.cell(row = index, column = 7, value = item.get('initial').get('down'))
ws.cell(row = index, column = 8, value = item.get('month').get('up'))
ws.cell(row = index, column = 9, value = item.get('month').get('normal'))
ws.cell(row = index, column = 10, value = item.get('month').get('down'))
wb.save('rank.xlsx')
目前創(chuàng)新互聯(lián)公司已為1000多家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)站空間、綿陽服務(wù)器托管、企業(yè)網(wǎng)站設(shè)計(jì)、鳳陽網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。