Generate (write data to) Excel file in Python

Source: Internet
Author: User

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

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.