Download a free 30 day trial of PyXLL and try it with your own data.
Since PyXLL was first released back in 2010 it has grown hugely in popularity and is used by businesses in many different sectors.
The original motivation for PyXLL was to be able to use all the best bits of Excel combined with a modern programming language for scientific computing, in a way that fits naturally and works seamlessly.
Since the beginning, PyXLL development focused on the things that really matter for creating useful real-world spreadsheets; worksheet functions and macro functions. Without these all you can do is just drive Excel by poking numbers in and reading numbers out. At the time the first version of PyXLL was released, that was already possibly using COM, and so providing yet another API to do the same was seen as little value add. On the other hand, being able to write functions and macros in Python opens up possibilities that previously were only available in VBA or writing complicated Excel Addins in C++ or C#.
With the release of PyXLL 3, integrating your Python code into Excel has become more enjoyable than ever. Many things have been simplified to get you up and running faster, and there are some major new features to explore.
- If you are new to PyXLL have a look at the Getting Started section of the documentation.
- All the features of PyXLL, including these new ones, can be found in the Documentation
NEW FEATURES IN PYXLL V. 3.0
1. Ribbon Customization
Ever wanted to write an add-in that uses the Excel ribbon interface? Previously the only way to do this was to write a COM add-in, which requires a lot of knowledge, skill and perseverance! Now you can do it with PyXLL by defining your ribbon as an XML document and adding it to your PyXLL config. All the callbacks between Excel and your Python code are handled for you.
See the Customizing the Ribbon for more detailed information or try the example included in the download.
2. RTD (Real Time Data) Functions
PyXLL can stream live data into your spreadsheet without you having to write any extra services or register any COM controls. Any Python function exposed to Excel through PyXLL can return a new RTD type that acts as a ticking data source; Excel updates whenever the returned RTD publishes new data.
See Real Time Data for more detailed information or try the example included in the download.
3. Function Signatures and Type Annotation
xl_func and xl_macro need to know the argument and return types to be
able to tell Excel how they should be called. In previous versions that was always done by passing a ‘signature’ string to these decorators.
Now in PyXLL 3 the signature is entirely optional. If a signature is not supplied PyXLL will inspect the function and determine the signature for you.
If you use Python type annotations when declaring the function, PyXLL will use those when determining the function signature. Otherwise all arguments and the return type will be assumed to be `var`.
4. Default Keyword Arguments
Python functions with default keyword arguments now preserve their default value when called from Excel with missing arguments. This means that a function like the one below
when called from Excel with b or c missing will be invoked with the correct default values for b and c.
def func_with_kwargs(a, b=1, c=2):
return a + b + c
5. Deep Reloading
If you’ve used PyXLL for a while you will have noticed that when you reload PyXLL only the modules listed in your pyxll.cfg file get reloaded. If you are working on a project that has multiple modules and not all of them are added to the config those won’t get reloaded, even if modules that are listed in the config file import them.
PyXLL can now track all the imports made by each module listed in the config file, and when you reload PyXLL all of those modules will be reloaded in the right order.
This feature is enabled in the config file by setting
deep_reload = 1
6. Error Caching
Sometimes it’s not convenient to have to pick through the log file to determine why a particular cell is failing to calculate.
The new function get_last_error takes an XLCell or a COM Range and returns the last exception (and traceback) to have occurred in that cell.
This can be used in menu functions or other worksheet functions to give end users better feedback about any errors in the worksheet.
7. Python Functions for Reload and Rebind
PyXLL can now be reloaded or it can rebind its Excel functions using the new Python functions reload and rebind.
8. Better win32com and comtypes Support
PyXLL has always had some integration with the pythoncom module, but it required some user code to make it really useful. It didn’t have any direct integration with the higher level win32com package or the
The new function xl_app returns the current Excel Application instance either as a pythoncom PyIDispatch instance, a win32com.client.Dispatch instance or a wrapped comtypes POINTER(IUnknown) instance.
You may specify which COM library you want to use with PyXLL in the pyxll.cfg file
com_package = <win32com, comtypes or pythoncom>
Download a free 30 day trial of PyXLL and see how PyXLL can help you use the power of Python to make Excel an even more powerful data analysis tool.