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:
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