-
-
Save Sven-Bo/aac3cedc026df6634b1a85e37c368214 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import xlwings as xw # pip install xlwings | |
EXCEL_FILE = Path(__file__).parent / 'YOUR_EXCEL_FILE.xlsx' | |
OUTPUT_DIR = Path(__file__).parent / 'Output' | |
# Create Output directory | |
OUTPUT_DIR.mkdir(parents=True, exist_ok=True) | |
with xw.App(visible=False) as app: | |
wb = app.books.open(EXCEL_FILE) | |
for sheet in wb.sheets: | |
wb_new = app.books.add() | |
sheet.copy(after=wb_new.sheets[0]) | |
wb_new.sheets[0].delete() | |
wb_new.save(OUTPUT_DIR / f'{sheet.name}.xlsx') | |
wb_new.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment