Skip to content
Related Articles
Open in App
Not now

Related Articles

Python Script to Automate Refreshing an Excel Spreadsheet

Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 14 Sep, 2021
Improve Article
Save Article

In this article, we will learn how we can automate refreshing an Excel Spreadsheet using Python.

So to open the Excel application and workbooks we are going to use the pywin32 module. You can install the module using the below code:

pip install pywin32

Then we are going to open the Excel application using the win32com.client.Dispatch() method and workbooks using the method.


Parameters: It will take the path of the excel file as its parameter.

And then use refresh the file using RefershAll():


For this example, we created an excel file named “Book1” with the below content:

Below is the implementation:


# Importing the pywin32 module
import win32com.client
# Opening Excel software using the win32com
File = win32com.client.Dispatch("Excel.Application")
# Optional line to show the Excel software
File.Visible = 1
# Opening your workbook
Workbook ="Book1.xlsx")
# Refeshing all the shests
# Saving the Workbook
# Closing the Excel File


My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!