Python for Excel Code Editor
January 18, 2025
Overview
We’re excited to announce a major update to our Python for Excel add-in that makes it easier than ever to create Excel LAMBDA functions from Python code. The new code editor provides a familiar VS Code-like experience right inside Excel, with features like syntax highlighting, function management, and integrated testing.
Key Features
Monaco Editor Integration
The add-in now includes the same editor (Monaco ) used in VS Code, providing:
- Syntax highlighting for Python
- Code completion and formatting
- Error detection
Function Management
A new Functions tab lets you:
- View all Python functions in your workbook
- Edit existing functions
- Delete unused functions
- Import functions from Jupyter notebooks
Testing Integration
Write test cases directly in your Python code:
def hello(first, last):
""" Returns a greeting. """
greeting = f"Hello {first, last}!"
return greeting
# Test cases for the function
test_cases = [["Nancy", "Morgan"], ["Ming", "Lee"]]
# Excel usage: =HELLO("Nancy", "Morgan")
Click “Test” to run your cases and see results in the Output tab.
How It Works
Creating a Python-powered LAMBDA function is now a two-step process:
- Write your Python function in the editor
- Click Save to create the LAMBDA
The Python code is stored in workbook settings and a corresponding LAMBDA function is automatically created in Excel’s name manager. For example, this Python function:
def inches_to_mm(inches):
""" Converts inches to millimeters. """
return inches * 25.4
Creates this LAMBDA in Excel:
=LAMBDA(inches, BOARDFLARE.EXEC("workbook-settings:inches_to_mm", inches))
Jupyter Notebook Integration
A particularly exciting feature is the ability to import functions from Jupyter notebooks. You can:
- Import from our example notebooks
- Load notebooks from GitHub Gists
- Use the notebooks as templates for your own functions
This makes it easy to maintain a library of functions in notebooks and import them into Excel as needed.
Try It Out
To get started with the new code editor:
- Install the Python for Excel add-in
- Open the task pane and go to the Editor tab
- Try writing a simple function or import one of our examples
- Click Save to create your LAMBDA function
The code editor is available now in version 1.1.0 of the add-in. For more details, check out our updated documentation.
What’s Next?
We’re continuing to improve the editor experience. Coming soon:
- Support for optional arguments
- More example notebooks
- Enhanced type conversion options
Let us know what features you’d like to see next!