MoonNote

반응형

 

 

엑셀 파일

Sample Sheet File.xlsx
0.01MB

 

엑셀 파일 구성

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

▪ 3행 4열 데이터셋

셀 데이터

▪ 3개 시트로 구성

엑셀 시트 정보

 

엑셀 시트 추가


  
import openpyxl
from openpyxl import 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")
# Create New Sheet
wb.create_sheet(title='New Sheet', index=0)
print(wb.sheetnames)

Result

['New Sheet', 'Sample Sheet', 'Sample Sheet (2)', 'Sample Sheet (3)']

 

엑셀 시트 삭제


  
import openpyxl
from openpyxl import 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")
# Remove Sheet
wb.remove(wb['Sample Sheet'])
print(wb.sheetnames)

Result

['Sample Sheet (2)', 'Sample Sheet (3)']

 

Openpyxl 함수 모음

 

 

 

 

 

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

 

 

 

공유하기

facebook twitter kakaoTalk kakaostory naver band