码迷,mamicode.com
首页 > 其他好文 > 详细

simple2.py

时间:2017-11-22 00:00:13      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:流量   write   coding   odi   str   cccccc   import   中心   enter   

 1 #coding: utf-8
 2 import xlsxwriter
 3 
 4 workbook = xlsxwriter.Workbook(chart.xlsx)
 5 worksheet = workbook.add_worksheet()
 6 
 7 chart = workbook.add_chart({type: column})
 8 
 9 title = [u业务名称,u星期一,u星期二,u星期三,u星期四,u星期五,u星期六,u星期日,u平均流量]
10 buname= [u业务官网,u新闻中心,u购物频道,u体育频道,u亲子频道]
11 
12 data = [
13     [150,152,158,149,155,145,148],
14     [89,88,95,93,98,100,99],
15     [201,200,198,175,170,198,195],
16     [75,77,78,78,74,70,79],
17     [88,85,87,90,93,88,84],
18 ]
19 format=workbook.add_format()
20 format.set_border(1)
21 
22 format_title=workbook.add_format()
23 format_title.set_border(1)
24 format_title.set_bg_color(#cccccc)
25 format_title.set_align(center)
26 format_title.set_bold()
27 
28 format_ave=workbook.add_format()
29 format_ave.set_border(1)
30 format_ave.set_num_format(0.00)
31 
32 worksheet.write_row(A1,title,format_title)
33 worksheet.write_column(A2, buname,format)
34 worksheet.write_row(B2, data[0],format)
35 worksheet.write_row(B3, data[1],format)
36 worksheet.write_row(B4, data[2],format)
37 worksheet.write_row(B5, data[3],format)
38 worksheet.write_row(B6, data[4],format)
39 
40 def chart_series(cur_row):
41     worksheet.write_formula(I+cur_row, 42      =AVERAGE(B+cur_row+:H+cur_row+),format_ave)
43     chart.add_series({
44         categories: =Sheet1!$B$1:$H$1,
45         values:     =Sheet1!$B$+cur_row+:$H$+cur_row,
46         line:       {color: black},
47         name:    =Sheet1!$A$+cur_row,
48     })
49 
50 for row in range(2, 7):
51     chart_series(str(row))
52 
53 #chart.set_table()
54 #chart.set_style(30)
55 chart.set_size({width: 577, height: 287})
56 chart.set_title ({name: u业务流量周报图表})
57 chart.set_y_axis({name: Mb/s})
58 
59 worksheet.insert_chart(A8, chart)
60 workbook.close()

 

simple2.py

标签:流量   write   coding   odi   str   cccccc   import   中心   enter   

原文地址:http://www.cnblogs.com/catgatp/p/7875603.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!