Python Execl write file data and generate graphs

Demand :

In order to do testing or crawlers crawling on the analysis of the data summary, our data will often generate reports, but if we want to generate reports in Excel, this time we can make use of third-party packages to generate charts xlsxwriter

Analysis :

Generating a multi-dimensional array is prepared excel types of data -> insert data into Excel -> data chart generated by series 

 The first step: to prepare the data:

Reptiles crawling using data on the network and on the top positions to generate a multi-dimensional array type, as follows:

= Data [
      [ "number of the IOS status", "the number of the Android status", "the number of positions the Python", "the number of jobs was networking", "Go to the chain number of block status"],
      [2000, 4000, 60000, 8000, 1000 ],
]

Step two: Insert data into Excel,

First create an Excel file, and then create a page in Excel sheet form, and finally insert data into sheet form page

1. Create an Excel object

workbook = xlsxwriter.Workbook(“Excel名字.xlsx”)

 2, a sheet form object is created based on Excel Object

worksheet = workbook.add_worksheet (name = "sheet form of the name, do not fill it defaults to sheet1")

 3, to write data sheet form page worksheet

worksheet.write_row( row, col, data, cell_format=None)

worksheet.write_column(row, col, data, cell_format=None)

3.1, may indicate that the first row of cells in the first column A1, the time data may be behind the array, a row of data directly into the

worksheet.write_column ( "A1", a column of data, comp

Guess you like

Origin blog.csdn.net/qq_42370150/article/details/104054213