import openpyxl
from openpyxl.styles import PatternFill, colors, Alignment, Font
def doExcel():
ex = openpyxl.load_workbook('/Users/gimdonghwan/파이썬강의준비/codingExcel.xlsx')
sheet = ex["sheet1"]
sheet.append([1, 2, 3, 4, 5])
sheet.append(["애쉬", "블리츠", "미스포츈", "나서스", "리신"])
#배경 색상.
patternRed = PatternFill(start_color="ff0000", fill_type="solid") #red
patternBlue = PatternFill(start_color=colors.BLUE, fill_type="solid") #blue
sheet.cell(3, 3).fill = patternRed
sheet.cell(3, 5).fill = patternBlue
#폰트 변경.
font24 = Font(name="나눔고딕", size=24, color=colors.BLUE)
sheet.cell(2,2).font = font24
sheet.cell(3,3).font = font24
#정렬 alignment
alignCenter = Alignment(horizontal="center", vertical="center")
for i in range(1, 6):
sheet.cell(1, i).alignment = alignCenter
#셀 크기 조절
sheet.row_dimensions[1].height = 100
sheet.column_dimensions["B"].width = 100
ex.save("/Users/gimdonghwan/파이썬강의준비/codingExcel.xlsx")
# Press the green button in the gutter to run the script.
if __name__ == '__main__':
doExcel()
# See PyCharm help at https://www.jetbrains.com/help/pycharm/