cover-img

Split Each Excel Sheet Into Separate Files

13 December, 2022

1

1

0

Overview

In this article, we will see how to split each Excel sheet into separate files. With the help of the xlwings Python module, we will first read the Excel file and then split it into separate files.

How to do?

Let’s have a look at the process step by step:
Step 1: Install the module given below.
Step 2: Import the following modules.
Step 3: Create a new Excel instance with xlwings.App, then set visibility to False if you don’t want the Excel window to appear. Then, using the books.open function, open the worksheet.
Step 4: We'll execute a loop to traverse each sheet. Copy each sheet to a new workbook using the api.copy method, activate the newly created workbook, save the workbook, and finally close the workbook.
Step 5: When you exit the excel sheet, you will notice that all of the sheets have been changed to new Excel files.

Code

Output

Before:
img

Before split

After:
img

All sheets are split into separate Excel files.

Wrap Up

In this tutorial, we take a look at the Python XLwings module. Using this module, we quickly and efficiently split each Excel Sheet into separate files.

Follow me on Twitter (@triposat).

Thanks!

python

excel

beginner

develevate

ms

1

1

0

python

excel

beginner

develevate

ms

Satyam Tripathi
Looking for DevRel πŸ₯‘ Role β€’ Open Source πŸš€ β€’ Content Writer πŸ‘©β€πŸ’»

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

Β© Copyright 2024. Showcase Creators Inc. All rights reserved.