![]() |
Home |
---|
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.
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.
# 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
In addition to Computer Science learners we also specialize in teaching and tutoring Python from intro to advanced modules like Pandas and Machine learning to Non computer science Python learners.
If you are not from CS We will train you that there will be no difference between your Python skills and CS programmers Python skills.
Python Programming for Beginners
& Advanced Level
for University Python Programming Course
for Practical tasks at work
Python Projects Help & Guidance
Automating your computing tasks
Join now to Advance in your Career
Python for Non Programmers Training
Machine Learning for Beginners Training
Deep Learning for Beginners Training
Pandas Data Analysis Tutoring
Numpy, Matplotlib, Scipy Tutoring
Keras, Tensorflow, Theano Tutoring
Flexible and Tailored for your Specific Needs
Live (1 on 1) Python Tutoring at Skype/Zoom
Learn Practical Examples
Work on Python Projects
High Quality Training from Experts
You may select your Syllabus for Tutoring
Flexible Timings: Select time which suits you
Guaranteed Learning
Home Tutorial Online Live Trainings Contact Us © 2023 All rights reserved by www.PythonTutor.net