Python Operations Excel table

Source: Internet
Author: User
Tags radar

Python Operations Excel table

#coding =utf-8

Import Xlsxwriter

#1. Creating an Excel Object

Work = Xlsxwriter. Workbook (' Hello.xlsk ') #在当前目录下创建一个Excel文件

#2. Create a table

Worksheet = work.add_worksheet (' int ')

#3. Writing content

Title_index = ["A", "B", "C", "D", "E", "F"]

title = ["int", "for", "while", "range", "MK", "two Dog". Decode ("Utf-8")]

data = [18,19,20,21,17,26]

#创建一个格式

B = Work.add_format ({"Blod": True})

For i,j in enumerate (title_index)

Point = "%s%s"% (j,1)

Content = Title[i]

Worksheet.write (POINT,CONTENT,B)

For i,j in Enumerate (title_index):

Point = "%s%s"% (j,2)

Content = Data[i]

Worksheet.write (point,content)

#数据统计

Worksheet.write ("G2", "=sum (A2:F2)")

#把数据在Excel表中生成图表

Chart = Work.add_chart ({"Type": "Column"}) #创建一个柱状图

#column Bar Chart

#area Area Chart

#bar Bar Chart

# line Chart

# Radar Radar Chart

Chart.add_series (

{

"categories": "=int! $A $ $F", #类别标签的范围

"Values": "=int! $A $ $F", #图标数据的范围

"line": {"color": "Red"} #图标线条的属性

})

Worksheet.insert_chart ("A4", chart)

#关闭并且保存操作

Work.close ()

Python action Excel table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.