tmp2.py 847 B

123456789101112131415161718192021222324252627282930313233
  1. ##############################################################################
  2. #
  3. # A simple example of some of the features of the XlsxWriter Python module.
  4. #
  5. # Copyright 2013-2017, John McNamara, jmcnamara@cpan.org
  6. #
  7. import xlsxwriter
  8. # Create an new Excel file and add a worksheet.
  9. workbook = xlsxwriter.Workbook('demo.xlsx')
  10. worksheet = workbook.add_worksheet()
  11. # Widen the first column to make the text clearer.
  12. worksheet.set_column('A:A', 20)
  13. # Add a bold format to use to highlight cells.
  14. bold = workbook.add_format({'bold': True})
  15. # Write some simple text.
  16. worksheet.write('A1', 'Hello')
  17. # Text with formatting.
  18. worksheet.write('A2', 'World', bold)
  19. # Write some numbers, with row/column notation.
  20. worksheet.write(2, 0, 123)
  21. worksheet.write(3, 0, 123.456)
  22. # Insert an image.
  23. worksheet.insert_image('B5', 'logo.png')
  24. workbook.close()