Python Tutoring Online
 Home            

Openpyxl Create Workbook()

In this article you will learn how to create a new workbook or excel file in python using openpyxl Workbook() function. The created workbook is empty with atleast one sheet in it. 

Syntax of Workbook()

First you need an import statement and then simply create a workbook reference object which points to the newly created excel file.

from openpyxl import Workbook

referenceobject = Workbook()

The import statement is only importing the Workbook class and later we create a workbook object to create a new workbook using Workbook() function.

Example: Workbook()

# import statement

>>>from openpyxl import Workbook

# create a new workbook

>>>mywb = Workbook()

# check type of object

>>>type(mywb)

<class 'openpyxl.workbook.workbook.Workbook'>

In this example a new workbook object mywb is created and its type is checked. The result shows that it is an openpyxl Workbook. This can be saved with a name and accessed later with that name.

A workbook is created with an active sheet, to access it use 

>>> mysheet = mywb.active



Stuck Learning Python?

Struggling with Python syntax, assignments or debugging errors? Learning alone can be frustrating.

Get 1-on-1 Python tutoring and learn faster with clear explanations, real examples and live help.

    Get Python Tutoring

Struggling to Learn Python?

Get 1-on-1 Python tutoring designed for beginners and professionals. Learn step-by-step with real examples and personal guidance.

✓ Understand Python fundamentals quickly

✓ Solve assignments and coding problems

✓ Learn automation and real-world projects

✓ Build confidence in programming

✓ Learn from Experts & Professionals


Start learning Python today

Book Your First Lesson

Need Help With Python Projects?

Get expert support with your Python assignments, coursework, data analysis tasks, and real programming projects.

✓ Python project guidance

✓ Machine learning basics

✓ Data analysis with Pandas & NumPy

✓ Debugging and code improvement

✓ Interview preparation help


Finish your Python project faster

Get Python Help

Become Confident in Python

Learn Python with structured lessons, real coding practice, and personalized feedback from an experienced tutor.

✓ Live online Python tutoring via Zoom

✓ Personalized learning plan

✓ Practical coding exercises

✓ Learn Python for work or career

✓ Flexible tutoring schedule


Build real Python skills

Start Learning Python


PythonTutor.net

Home    Tutorial     Online Live Trainings    Contact Us           © 2026 All rights reserved by www.PythonTutor.net