How to Create an Excel File with Customised Sheet Names Using Python

Working with Excel is a daily routine for many professionals, but doing repetitive tasks manually can be time‑consuming. Python, with its powerful libraries, makes Excel automation simple and efficient. In this post, we’ll walk through how to create an Excel file with customised sheet names using the openpyxl library.

 

Why Use Python for Excel?

  • Automation: No more clicking “Insert Sheet” ten times.
  • Consistency: Sheet names follow a standard pattern every time.
  • Scalability: Easily generate dozens of sheets for reports, logs, or student records.

 

Step‑by‑Step Guide

1. Install openpyxl

pip install openpyxl

 

2. Import Workbook

from openpyxl import Workbook

This creates a new Excel workbook object.

 

3. Define Your Sheet Names

sheet_names = ["Sales_Jan", "Sales_Feb", "Sales_Mar"]

Here we’re preparing a list of names for our sheets.

 

4. Remove the Default Sheet

wb = Workbook()

wb.remove(wb.active)

Excel files start with one sheet named “Sheet”. We remove it to start fresh.

 

5. Create Custom Sheets

for name in sheet_names:

    wb.create_sheet(title=name)

This loop adds new sheets with the names you defined.

 

6. Save the File

wb.save("sales_report.xlsx")

Your Excel file is now ready with customised sheet names.

 

 

Full Code:

from openpyxl import Workbook

 

wb = Workbook()

sheet_names = ["Sales_Jan", "Sales_Feb", "Sales_Mar"]

wb.remove(wb.active)

 

for name in sheet_names:

    wb.create_sheet(title=name)

 

wb.save("sales_report.xlsx")

 

 

Real‑World Applications

  • Monthly reports: Automatically generate sheets for each month.
  • IoT data logging: ESP32 or STM32 boards can push sensor data into separate sheets.
  • Education: Teachers can prepare sheets for each class or subject.

 

 

Final Thoughts

With just a few lines of Python, you can save hours of manual work in Excel. The beauty of automation is that once you set it up, it runs consistently every time. Whether you’re managing sales data, teaching students, or logging IoT sensor readings, customised sheet names make your Excel files neat and professional.