Practice1 [엑셀 자동화] 엑셀 데이터 접근 Practice 1. 출생년도에 따른 나이 from datetime import datetime import openpyxl as excel book = excel.Workbook() sheet = book.worksheets[0] # 올해 년도(2024년) thisyear = datetime.now().year # 헤더 설정 sheet['A1'] = "출생년도" sheet['B1'] = "나이" # 현재 년도부터 100년 이전까지의 나이 계산 for i in range(101): a_col = sheet.cell(i+2, 1) # 출생년도 열 b_col = sheet.cell(i+2, 2) # 나이 열 a_col.value = str(thisyear - i) + "년생" b_col.value = str(i+1) + ".. 2024. 2. 17. 이전 1 다음 728x90