Skip to content

Instantly share code, notes, and snippets.

@leisurelicht
Created April 8, 2019 03:49
Show Gist options
  • Save leisurelicht/e830c8225ca722ab4bbb23c9255ec699 to your computer and use it in GitHub Desktop.
Save leisurelicht/e830c8225ca722ab4bbb23c9255ec699 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*-coding: utf-8-*-
import datetime
import xlwt
workbook = xlwt.Workbook()
worksheet = workbook.add_sheet('My Sheet')
# style = xlwt.XFStyle()
style = xlwt.easyxf(num_format_str='YYYY/MM/DD HH:MM')
style.num_format_str = 'M/D/YY'
# Other options: D-MMM-YY, D-MMM, MMM-YY, h:mm, h:mm:ss, h:mm, h:mm:ss, M/D/YY h:mm, mm:ss, [h]:mm:ss, mm:ss.0
worksheet.write(0, 0, datetime.datetime.now(), style)
workbook.save('Excel_Workbook.xls')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment