Python Tutoring Online
 Home            

Openpyxl Save Workbook

In this article you will learn how to save a workbook in python using openpyxl save() function. You may use "save" or "save as" option with the same function.

Syntax of save()

If you want to save a newly created file with a new name

file = "filename.xlsx"

workbook.save(file)

There are two options save and save as for existing files. If you want to save a file with save option use the old file name in save() function. In case you want to use save as option, use a new file name and save it.

Example 1: openpyxl save()

For a new excel workbook the example for saving a file is

>>> file = "newfile.xlsx"

>>> workbook.save(file)

As this is a new file and we are saving it for the first time, hence a new file name is created and provided to the save function. workbook is the workbook object we want to save.

Example 2: with "save" option

After editing or modifying an existing file, if you want to save it with save option write

>>> workbook.save("oldfilename.xlsx")

In this case simply use the old file name and the excel file will be modified, however you will not be able to access the old non-edited file.

Example 3: with "save as" option

If you want to save an existing file with a new name use save as option. 

>>> file = "newfilename.xlsx"

>>> workbook.save(file)

Use this option if you want to save the data as you will be saving in a new file and the old file will still be there and accessible.

Non Computer Science Background Students

We Specialize in teaching and tutoring Python from intro to advanced modules like Pandas and Machine learning to Non Programming and 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.

Join Now

Python Programming online tutors


Python Programming for Beginners

Python for Advanced Level

for University Python Programming Course

for Practical tasks at work

Python Projects Help & Guidance

Automating your computing tasks


Learn Python, Advance in your Career Join Now

For More information

Python Trainings Online


Python for Non Programmers Training

Machine Learning for Beginners Training

Deep Learning for Beginners Training

Python Pandas Training Tutors

Numpy, Matplotlib, Scipy Tutors

Keras, Tensorflow, Theano Tutors


Flexible and Tailored for your Specific Needs

More info on Trainings

Python Online Training Features


Live (1 on 1) Python Tutoring at Skype

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

Join Course

PythonTutor.net

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