python-excel.org

Working with Excel Files in Python

This site is a guide to the tools available for working with Excel and Python. There are two main approaches: Processing Excel files from Python — reading, writing, and manipulating .xlsx files without needing Excel installed; and, Integrating Python and Excel — building add-ins, user-defined functions, and automating the Excel application itself.

Reading and Writing Excel Files

There are python packages available to work with Excel files that will run on any Python platform and that do not require either Windows or Excel to be used. They are fast, reliable and open source:

openpyxl

A mature, widely used, package for reading and writing Excel 2010 files (ie: .xlsx)

xlsxwriter

An alternative package for writing data, formatting information and, in particular, charts in the Excel 2010 format (ie: .xlsx)

WolfXL

An openpyxl-compatible package with a Rust backend for reading, writing, and editing Excel files (.xlsx, .xlsm), including in-place edits of existing templates. The free Community edition is MIT-licensed.

WolfXL Commercial adds a native formula engine verified against Excel-calculated results, rendering of sheets and charts to PDF or PNG, and direct support.

pyexcel

Library with a unified api for reading and writing files with older Excel format (xls), Excel 2010 format (xlsx), OpenDocument Spreadsheet format (ods), and many others.

pyxlsb

This package allows you to read Excel files in the xlsb format.

pylightxl

This package allows you to read xlsx and xlsm files and write xlsx files.

xlrd

This package is for reading data and formatting information from older Excel files (ie: .xls)

xlwt

This package is for writing data and formatting information to older Excel files (ie: .xls)

NB: xlwt is no longer maintained and the .xls format is largely obsolete. For writing Excel files, use openpyxl or xlsxwriter instead.

xlutils

This package collects utilities that require both xlrd and xlwt, including the ability to copy and modify or filter existing excel files.

NB: In general, these use cases are now covered by openpyxl!

Integrating Python and Excel

The following products can be used to integrate Python and Excel. For example, writing Excel add-ins in Python and/or automating Excel.

Unlike the reader and writer packages, they require an installation of Microsoft Excel.

PyXLL

PyXLL is a commercial Excel add-in that embeds a full Python interpreter directly inside Excel, enabling you to build high-performance add-ins entirely in Python with no VBA.

It embeds Python locally, in-process, in Excel. It is significantly faster, and more robust, than out-of-process or cloud based approaches.

Python functions are exposed as worksheet functions (UDFs), macros, menus, and ribbon toolbars. PyXLL gives you complete access to the Excel object model and the full Python ecosystem — including NumPy, pandas, matplotlib, and any other package you can install locally. It supports real-time data (RTD) functions for live data feeds, custom task panes, and Excel automation.

xlwings

xlwings is an open-source library to automate Excel with a Python script running out-of-process. You can automate Excel with Python on Windows and macOS, and write UDFs in Python (Windows only, uses VBA).

xlwings PRO is a commercial add-on with additional functionality.

What's the difference between PyXLL and xlwings?

Microsoft's "Python in Excel"

Microsoft introduced Python in Excel as a built-in feature for Microsoft 365 subscribers, allowing Python code to be written directly in Excel cells with results returned as values or images.

Python in Excel runs using an Anaconda distribution hosted in Microsoft's cloud, so the code has no access to local files, databases, or network resources — all data must be loaded into the workbook. Code is embedded in cells rather than .py files, making it hard to version-control or reuse across workbooks. Note also that Python cells recalculate in strict top-to-bottom order rather than following Excel's normal dependency graph.

Microsoft documentation

For use cases that require local data access, reusable code, or deeper Excel integration, PyXLL is worth considering.

What are the differences between PyXLL and Microsoft's "Python in Excel"?


For a more detailed comparison of some of the tools mentioned above, see the blog post Tools for Working with Excel and Python on the PyXLL blog.

The Mailing List / Discussion Group

There is a Google Group dedicated to working with Excel files in Python, including the libraries listed above along with manipulating the Excel application via COM.

Commercial Development

The following companies can provide commercial software development and consultancy and are specialists in working with Excel files in Python:

Clark Consulting & Research
Clark Consulting & Research