Last active
March 31, 2017 13:27
-
-
Save ultrakain/7dac03dc4fcca0cb384314b20ee59c54 to your computer and use it in GitHub Desktop.
write excel with openpyxl
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
from openpyxl import Workbook | |
from openpyxl.styles import Font, PatternFill | |
wb = Workbook() | |
dest_filename = 'empty_book.xlsx' | |
ws1 = wb.active | |
ws1.title = u"샘플" | |
ws1['A1'] = '과일종류' | |
ws1['A2'] = '메론' | |
ws1['A3'] = '딸기' | |
ws1['A4'] = '바나나' | |
ws1['A5'] = '호박' | |
ws1['A6'] = '집계' | |
ws1['B1'] = '재고' | |
ws1['B2'] = 10 | |
ws1['B3'] = 2 | |
ws1['B4'] = 22 | |
ws1['B5'] = 10 | |
ws1['B6'] = '=SUM(B2:B5)' | |
# 스타일 적용 | |
fill = PatternFill("solid", fgColor="bd7c05") | |
ws1['A1'].fill = fill | |
ws1['B1'].fill = fill | |
wb.save(filename = dest_filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment