Transfer from http://www.crifan.com/export_data_to_excel_file_in_python/
In Python, how to export data to Excel, that is, to write data to the newly generated Excel file.
1. See online:
Working with Excel Files in Python
These include, in Python, how to read Excel files, how to write data to Excel files, and so on related libraries.
It should look like this is the best thing to summarize.
2. For the time being, just write the data to Excel, so refer to:
XLWT examples
Take a look at the sample code:
https://github.com/python-excel/xlwt/blob/master/xlwt/examples/simple.py
It seems simple to use.
Then go to the homepage:
Http://pypi.python.org/pypi/xlwt
After downloading xlwt-0.7.4.tar.gz, unzip.
Then refer to:
Https://secure.simplistix.co.uk/svn/xlwt/trunk
Https://secure.simplistix.co.uk/svn/xlwt/trunk/README.html
Go to install with setup.py installation:
Then continue to refer to:
Https://secure.simplistix.co.uk/svn/xlwt/trunk/README.html
To try the sample code:
ImportXLWT fromDatetimeImportdatetime STYLE0= XLWT.EASYXF ('font:name times New Roman, Color-index red, bold on', num_format_str='#,# #0. XX') Style1= XLWT.EASYXF (num_format_str='D-mmm-yy') WB=XLWT. Workbook () WS= Wb.add_sheet ('A Test Sheet') ws.write (0, 0,1234.56, Style0) ws.write (1, 0, DateTime.Now (), Style1) Ws.write (2, 0, 1) Ws.write (2, 1, 1) Ws.write (2, 2, XLWT. Formula ("a3+b3")) Wb.save ('Example.xls')
Then it can execute normally, generate the corresponding Excel file, the effect is:
Generate (write data to) Excel file in Python