How to get sheet names using openpyxl - Python Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The openpyxl library is widely used to handle excel files using Python. Often when dealing with excel files one might have noticed multiple sheets. The sheets are normally mentioned in the bottom left corner of the screen. One can install this library by running the following command. pip install openpyxl In this article, we will be seeing how to get the names of these sheets and display them using openpyxl. The file we will be using here is named Example.xlsx and has the following sheets. Python Codde to get sheet names using Openpyxl First, we need to import the openpyxl library. After this, we will load our excel sheet Example.xlsx. Then by using the function sheetnames we can get a list of names of all the sub sheets that are present in the main sheet. Python3 # importing the openpyxl module as xl import openpyxl as xl # excel file used here gfg.xlsx excel_file = "Example.xlsx" # load the workbook wb = xl.load_workbook(excel_file) # print the list that stores the sheetnames print(wb.sheetnames) # we can also get the name of the sheet which is active by using the active property print("Active sheet: ", wb.active) # By default the active sheet is the 1st one and can be changed wb._active_sheet_index = 4 sheet = wb.active print("Active sheet: ", wb.active) Output: ['sales_q1', 'sales_q3', 'sales_q4', 'sales_q2', 'sales_monthly'] Active sheet: <Worksheet "sales_q1"> Active sheet: <Worksheet "sales_monthly"> Comment More infoAdvertise with us Next Article How to get sheet names using openpyxl - Python arorapranay Follow Improve Article Tags : Technical Scripter Python Technical Scripter 2022 Practice Tags : python Similar Reads Writing to an excel sheet using Python Using xlwt module, one can perform multiple operations on spreadsheet. For example, writing or modifying the data can be done in Python. Also, the user might have to go through various sheets and retrieve data based on some criteria or modify some rows and columns and do a lot of work. Let's see how 2 min read How to delete one or more rows in excel using Openpyxl? Openpyxl is a Python library to manipulate xlsx/xlsm/xltx/xltm files. With Openpyxl you can create a new Excel file or a sheet and can also be used on an existing Excel file or sheet. Installation This module does not come built-in with Python. To install this type the below command in the terminal. 5 min read Formatting Cells using openpyxl in Python When it comes to managing Excel files programmatically, Python offers a powerful tool in the form of the openpyxl library. This library not only allows us to read and write Excel documents but also provides extensive support for cell formatting. From fonts and colors to alignment and borders, openpy 4 min read Export Data From Mysql to Excel Sheet Using Python We are given a MySQL database and our task is to export the data into an excel sheet using Python. In this article, we will see how to export data from MySQL to Excel Sheets using Python. Export Data From Mysql to Excel Sheet Using PythonBelow are some of the ways by which we can export data from My 3 min read Merge and Unmerge Excel Cells using openpyxl in Python In this article, we are going to learn about Python programs to merge and unmerge excel cells using openpyxl.IntroductionOpenpyxl is a Python library commonly used for reading and writing Excel Files. In this article, we will be using this library to merge cells in Excel. Merging is helpful when we 4 min read Python | Writing to an excel file using openpyxl module Prerequisite : Reading an excel file using openpyxl Openpyxl is a Python library for reading and writing Excel (with extension xlsx/xlsm/xltx/xltm) files. The openpyxl module allows Python program to read and modify Excel files. For example, user might have to go through thousands of rows and pick o 3 min read Reading an excel file using Python openpyxl module Openpyxl is a Python library for reading and writing Excel (with extension xlsx/xlsm/xltx/xltm) files. The Openpyxl Module allows Python programs to read and modify Excel files. For example, users might have to go through thousands of rows and pick out a few handfuls of information to make small cha 3 min read How To Print A Variable's Name In Python In Python, printing a variable's name can be a useful debugging technique or a way to enhance code readability. While the language itself does not provide a built-in method to directly obtain a variable's name, there are several creative ways to achieve this. In this article, we'll explore five simp 3 min read Python | Plotting charts in excel sheet using openpyxl module | Set - 1 Prerequisite: Reading & Writing to excel sheet using openpyxl Openpyxl is a Python library using which one can perform multiple operations on excel files like reading, writing, arithmetic operations and plotting graphs. Let's see how to plot different charts using realtime data. Charts are compo 6 min read Python | Plotting charts in excel sheet using openpyxl module | Set 3 Prerequisite : Plotting charts in excel sheet using openpyxl module Set - 1 | Set â 2Openpyxl is a Python library using which one can perform multiple operations on excel files like reading, writing, arithmetic operations and plotting graphs. Charts are composed of at least one series of one or more 7 min read Like