Last active
August 29, 2015 13:58
-
-
Save photonxp/10015096 to your computer and use it in GitHub Desktop.
demo usage for xlsxwriter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# the demo code is from https://pypi.python.org/pypi/XlsxWriter | |
import xlsxwriter | |
# Create an new Excel file and add a worksheet. | |
workbook = xlsxwriter.Workbook('demo.xlsx') | |
worksheet = workbook.add_worksheet() | |
# Widen the first column to make the text clearer. | |
worksheet.set_column('A:A', 20) | |
# Add a bold format to use to highlight cells. | |
bold = workbook.add_format({'bold': True}) | |
# Write some simple text. | |
worksheet.write('A1', 'Hello') | |
# Text with formatting. | |
worksheet.write('A2', 'World', bold) | |
# Write some numbers, with row/column notation. | |
worksheet.write(2, 0, 123) | |
worksheet.write(3, 0, 123.456) | |
# Insert an image. | |
worksheet.insert_image('B5', 'logo.png') | |
workbook.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment