Skip to content

Instantly share code, notes, and snippets.

@not-for-me
Created October 20, 2014 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save not-for-me/96befc18e77ee892a9d9 to your computer and use it in GitHub Desktop.
Save not-for-me/96befc18e77ee892a9d9 to your computer and use it in GitHub Desktop.
Make Excel File with Python
# coding: utf-8
from xlwt import Workbook
book = Workbook()
sheet1 = book.add_sheet(u'Ex Sheet1')
sheet2 = book.add_sheet(u'Ex Sheet2')
sheet1.write(0,0, u'Name')
sheet1.write(0,1, u'Sex')
row0 = sheet1.row(0)
row0.write(2, u'Nation')
# Style
sheet1.col(0).width = 5000
# 덮어쓰기 하면 안 됨
try:
pass
# row0.write(2, u'Rewrite')
except Exception as e:
print(u'Error: {0}'.format(e))
# 덮어쓰기 가능하게 옵션 주고 sheet 생성
sheet_overwrite = book.add_sheet(u'Rewritable', cell_overwrite_ok=True)
sheet_overwrite.write(0,0, u'First')
sheet_overwrite.write(0,0, u'Second')
sheet2.write(0,0, u'Test')
sheet2.write(1,0, u'Test2')
book.save('simple.xls')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment