MoonNote

반응형
     

 

 

 

엑셀 파일

Sample Sheet File.xlsx
0.01MB

 

엑셀 파일 구성

예제 실행시 사용하였던 엑셀 파일 데이터 및 시트 정보

▪ 3행 4열 데이터셋

셀 데이터

▪ 3개 시트로 구성

엑셀 시트 정보

 

엑셀 이름 출력

import openpyxl

# You must change the physical path before running this script.
currPath = "C:/Users/natio/OneDrive - 성균관대학교/99. Personal Blog/05. Python/05. OPENPYXL_XLRD_XLWT/01. Excel Sheet/"

wb = openpyxl.load_workbook(filename=currPath+"Sample Sheet File.xlsx")
ws = wb.active

# print the sheet name
print('Active sheet name : ', ws.title)

Result

Active sheet name : Sample Sheet

 

엑셀 시트 개수 확인

import openpyxl

from openpyxl import load_workbook

# You must change the physical path before running this script.
currPath = "C:/Users/natio/OneDrive - 성균관대학교/99. Personal Blog/05. Python/05. OPENPYXL_XLRD_XLWT/01. Excel Sheet/"

# # Load the excel file
wb = openpyxl.load_workbook(filename=currPath+"Sample Sheet File.xlsx")
res = len(wb.sheetnames)

# Number of sheets
print('Number of sheets : ', res, 'sheets')

Result

Number of sheets :  3 sheets

Openpyxl 함수 모음

 

 

 

 

 

 

 

 

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

 

 

 

공유하기

facebook twitter kakaoTalk kakaostory naver band