simple.py 465 B

123456789101112131415161718192021222324
  1. import xlwt
  2. from datetime import datetime
  3. font0 = xlwt.Font()
  4. font0.name = 'Times New Roman'
  5. font0.colour_index = 2
  6. font0.bold = True
  7. style0 = xlwt.XFStyle()
  8. style0.font = font0
  9. style1 = xlwt.XFStyle()
  10. style1.num_format_str = 'D-MMM-YY'
  11. wb = xlwt.Workbook()
  12. ws = wb.add_sheet('A Test Sheet')
  13. ws.write(0, 0, 'Test', style0)
  14. ws.write(1, 0, datetime.now(), style1)
  15. ws.write(2, 0, 1)
  16. ws.write(2, 1, 1)
  17. ws.write(2, 2, xlwt.Formula("A3+B3"))
  18. wb.save('example.xls')