Featured Article

Does Excel Run on Python?

Evelyn Jul 13, 2026

The intersection of Excel and Python often sparks curiosity, prompting users to ask: "Does Excel run on Python?" While Excel isn't designed to 'run' on Python, the two can indeed work together seamlessly, thanks to Python's reach into the Excel ecosystem. Let's dive into this dynamic duo and explore how they collaborate.

Data Science Tutorials | DataCamp Blogs
Data Science Tutorials | DataCamp Blogs

Excel, a mainstay of the business world, is moonlighting as a data analyst's best friend, while Python, with its powerful data manipulation and visualization libraries, is quickly becoming the data analyst's right hand. So, how can these two seemingly different tools harmonize? Let's find out.

a woman standing in front of a poster with the words python in excel on it
a woman standing in front of a poster with the words python in excel on it

Python's Access to Excel

Python's ability to interact with Excel files is the first step towards their harmonious marriage. Python, equipped with libraries like pandas and openpyxl, can read, write, and modify Excel files with ease.

How to Automate an Excel Sheet in Python? - GeeksforGeeks
How to Automate an Excel Sheet in Python? - GeeksforGeeks

The pandas library, which is Python's data manipulation workhorse, uses the pd.read_excel() function to read Excel files into dataframes – a tabular data structure that's perfect for data manipulation. Similarly, it uses the df.to_excel() method to write dataframes to Excel files.

Reading Excel Files

Fastest Way to Read Excel in Python
Fastest Way to Read Excel in Python

To read an Excel file with pandas, you'd typically do something like this:

import pandas as pd
df = pd.read_excel('file.xlsx')
print(df.head())

Writing to Excel Files

Writing to an Excel file is just as straightforward:

a screenshot of a computer screen with the text reading test baking records on it
a screenshot of a computer screen with the text reading test baking records on it

import pandas as pd
data = [{'Name': 'John', 'Age': 30}, {'Name': 'Jane', 'Age': 25}]
df = pd.DataFrame(data)
df.to_excel('output.xlsx', index=False)

Python in Excel: Automating Tasks

You might be wondering if Python has a presence within Excel itself. Yes, it does! Python can be used within Excel to automate tasks via the Python for Excel (PyXLL) add-in. This allows you to run Python code directly in Excel cells, creating a powerful hybrid of Python's data analysis capabilities and Excel's user interface.

Once PyXLL is installed, you can use Python functions within Excel cells, just like you would with traditional Excel functions. This opens up a world of possibilities for automating manual data tasks, complex calculations, and data visualizations.

xlwings Tutorial: Make Excel Faster Using Python – Dataquest
xlwings Tutorial: Make Excel Faster Using Python – Dataquest

Creating a Simple Python Function in Excel

Let's create a simple Python function that adds two numbers and use it in Excel:

How to create, read, update and search through Excel files using Python
How to create, read, update and search through Excel files using Python
an image of two different types of programming
an image of two different types of programming
Ezekiel (@ezekiel_aleke) on X
Ezekiel (@ezekiel_aleke) on X
Can Excel Use Python?
Can Excel Use Python?
How To Use Python To Manage an Excel Spreadsheet?
How To Use Python To Manage an Excel Spreadsheet?
PyXLL - The Python Excel Add-in
PyXLL - The Python Excel Add-in
a woman is looking at the camera and has her hand on her chin, with text that reads 1 - min python hacks in excel
a woman is looking at the camera and has her hand on her chin, with text that reads 1 - min python hacks in excel
Python in Excel alternative: Open. Self-hosted. No limits.
Python in Excel alternative: Open. Self-hosted. No limits.
Python in Excel : Easily Unlock Advanced Data Analytics
Python in Excel : Easily Unlock Advanced Data Analytics
  1. Install PyXLL using pip: pip install pyxll
  2. Open Excel, go to the PyXLL tab and click 'Install PyXLL'
  3. Create a new VBA module (Insert > Module) and paste the following code:

Function AddNumbers(a As Variant, b As Variant) As Variant
    AddNumbers = a + b
End Function

Now, you can use the 'AddNumbers' function in any Excel cell as you would with built-in functions like SUM().

embroiled in their respective ecosystems, Excel and Python might seem like an odd couple. However, with the right tools and techniques, they work together harmoniously, each bringing its unique strengths to the table. From Python's powerful data manipulation and automation capabilities to Excel's robust user interface and data presentation, this dynamic duo is a force to be reckoned with in the data analysis landscape.