MoonNote

반응형
     

 

 

 

엑셀 파일(실행 후 결과 값)

Openpyxl Coordinate Example.xlsx
0.00MB

 

엑셀 파일 구성

코드 실행 후 파일 저장

A1 : Hello,      B1 : World,      C1 : Created by MoonNote

셀 데이터

 

좌표 출력(Coordinate) 예제 코드

cell.coordinate : 현재 작업 중인 좌표의 위치를 출력할 때 사용

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

A1
B2
C3

Created Excel file

셀 데이터

 

 

Openpyxl 함수 모음

 

 

 

 

 

 

 

 

※ 이 글이 도움이 되었다면 "👆🏻구독"과 "🤍공감" 버튼을 클릭해주세요. 클릭 한번이 글 쓰는데 큰 힘이 됩니다.

 

공유하기

facebook twitter kakaoTalk kakaostory naver band