Xlsxwriter Learning record of Python learning

Source: Internet
Author: User

Today I would like to try to operate Excel, on the Internet to find a bit of information, began to practice. I am operating under Linux.

: https://pypi.python.org/pypi/XlsxWriter/0.6.8

I am under the source package, using the python3.3 to operate.

In the source code package has examples directory, below is an example. Begin:

    1. Starting from HelloWorld

hello.py
#!/usr/local/bin/python3.3
Import Xlsxwriter as WX
Workbook = wx. Workbook (' hello.xlsx ') worksheet = Workbook.add_worksheet () worksheet.set_column (' A:a ', Len (' Hello World ') +1) Worksheet.write (0, 0, ' Hello World ') workbook.close ()

is to create the file, then add sheet, then set the following width, write the data, and then close.

One of the Set_column ' A:a ' is a column range, here is column A, if it is a to E column is ' A:e '.

2. Here is the image.py in the exercise

#!/usr/local/bin/python3.3
Import Xlsxwriter as WX
Workbook = wx. Workbook (' images.xlsx ') Worksheet1 = Workbook.add_worksheet () worksheet1.set_column (' a:a ', ') worksheet1.write (' A2 ') , ' Insert an image in a cell: ') worksheet1.insert_image (' B2 ', ' python.png ')
Worksheet1.write (' A12 ', ' Insert an image with an offset ') worksheet1.insert_image (' B12 ', ' python.png ', {' X_offset ': 10, ' Y_offset ': 10})
Worksheet1.write (' A22 ', ' Insert a scaled Image: ') worksheet1.insert_image (' B22 ', ' python.png ', {' X_scale ': 0.2, ' y_ ') Scale ': 0.2})
Workbook.close ()

Let's find a. png image, change it to python.png, and then use it.

One is normal to add a picture, one is to specify the cell after the offset, one is scaled, of course, is called scaling, is to be able to put, write large

In 1 is the amplification effect.













Xlsxwriter Learning record of Python learning

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.