파이썬 python

파이썬 초보 프로젝트 엑셀 다루기 2편 - 파이썬으로 엑셀 작성하기

studying develop 2021. 8. 20. 00:01
import openpyxl

def doExcel():
    ex = openpyxl.Workbook() #엑셀 생성.
    ex.create_sheet("sheet1") #테스트 시트 추가.
    sheet = ex["sheet1"] #시트 선택

    sheet['A1'] = "i'm jacy"
    sheet['B1'] = "hello"
    sheet.cell(1, 3, 30)
    sheet.cell(row=1, column=4, value=40)
    sheet.cell(1, 5, "=SUM(C1:D1)/2")

    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/