코드 실행 후 파일 저장
▪ A1 : Hello, B1 : World, C1 : Created by MoonNote
cell.coordinate : 현재 작업 중인 좌표의 위치를 출력할 때 사용
Copy from openpyxl import Workbook # Create a new workbook workbook = Workbook() # Select the activated workbook sheet = workbook.active # Write the A1 value to 'Hello' sheet['A1'] = 'Hello' # The coordinate output of the A1 cell cell = sheet['A1'] print(cell.coordinate) # Output: A1 # Write the B2 value to 'World' sheet['B2'] = 'World' # The coordinate output of the B2 cell cell = sheet.cell(row=2, column=2) print(cell.coordinate) # Output: B2 # Write the C3 value to 'World' sheet['C3'] = 'Created by MoonNote' # The coordinate output of the C3 cell cell = sheet['C3'] print(cell.coordinate) # Output: C3 # save the file workbook.save('Openpyxl Coordinate Example.xlsx')
Result
Created Excel file
Openpyxl 함수 모음
※ 이 글이 도움이 되었다면 "👆🏻구독"과 "🤍공감" 버튼을 클릭해주세요. 클릭 한번이 글 쓰는데 큰 힘이 됩니다.
* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.