A C++ library for reading, writing, creating and modifying Microsoft Excel® (.xlsx) files.
A C++ library for reading, writing, creating and modifying Microsoft Excel® (.xlsx) files.
OpenXLSX is a C++ library for reading, writing, creating and modifying Microsoft Excel® files, with the .xlsx format.
NOTE: With today's release v0.5.1, this repository is discontinued on github. It has been migrated to Codeberg, and will eventually be moved to @troldal's Codeberg.
Please do not open any more issues or pull requests on github, and instead submit your feature requests directly on Codeberg.
After creating an account on codeberg.org, you will be able to "own" and edit issues and comments previously created by you by linking your github account to codeberg via "Sign in with Github", direct link here.
This version, with updates from 2026-06-13, is the latest release.
Note: generally, for features awaiting implementation, refer to the open issues in the repository
BUILD_SHARED_LIBS functionality in Makefile.GNUMakefile.GNU, check for available dependencies and error out if any are missingFor the latest functionality updates, please refer to the development branch. Feel free to have a look. This way you don't have to wait until the main repository is updated.
0.5.1 - git tag will be updated in one of the next commitsOPENXLSX_MONOLITHIC_LIBRARY requires static, BUILD_SHARED_LIBS requires shared dependencies) and triggering (if enabled) automatic download from upstream if the required dependency is not availablevoid XLWorksheet::setDimension functions to set it, with auto-calculation of last cell, if desired. This addresses issue 361. Supported function overloads:void XLWorksheet::setDimension(XLCellReference topLeft, XLCellReference bottomRight, bool autoCalculateLastCell);
void XLWorksheet::setDimension(std::string topLeft, std::string bottomRight);
void XLWorksheet::setDimension(std::string dimension);-DOPENXLSX_MONOLITHIC_LIBRARY=ON - this requires static dependencies and only works with miniz, fails with libzip (or rather: the libzip (sub-)dependencies will not be linked into the resulting bundled library)OpenXLSXFileSystemTools.hpp pathExists), nowide::stat is now used when nowide is in use. This should make calls to XLDocument::create and XLDocument::saveAs behave well with filenames containing unicode charactersOpenXLSXFileSystemTools fileSize to wrap call to stat with nowide compatibility - this is used in LibZip.hpp loadArchiveDataChange history is found in the detailed change log.
After a long period of inactivity, I have decided to resume development of OpenXLSX. The code has been cleaned up and a significant number of bugs have been fixed. The library has been tested on Windows, macOS and Linux, and should work on all platforms.
I would like to extend my sincere thanks to all the people who have contributed to the project, either by reporting bugs, suggesting features or by submitting pull requests. I would also like to thank all the people who have starred the project, and who have shown interest in the project.
In particular, I would like to thank Lars Uffmann (https://codeberg.org/lars_uffmann/) for his contributions to the project. Lars has spent significant time and effort in cleaning up the code, fixing bugs and implementing new features. Without his help, the project would not have been in the state it is today.
Many programming languages have the ability to modify Excel files, either natively or in the form of open source libraries. This includes Python, Java and C#. For C++, however, things are more scattered. While there are some libraries, they are generally less mature and have a smaller feature set than for other languages.
Because there are no open source library that fully fitted my needs, I decided to develop the OpenXLSX library.
The ambition is that OpenXLSX should be able to read, write, create and modify Excel files (data as well as formatting), and do so with as few dependencies as possible. Currently, OpenXLSX depends on the following 3rd party libraries:
-DOPENXLSX_ENABLE_LIBZIP=ONAs of version 0.5.0, these libraries are no longer included in the repository, and there are three ways to build OpenXLSX against them:
find_packagegitAlso, focus has been put on speed, not memory usage (although there are options for reducing the memory usage, at the cost of speed; more on that later).
OpenXLSX has been tested on the following platforms/compilers. Note that a '-' doesn't mean that OpenXLSX doesn't work; it just means that it hasn't been tested:
| GCC | Clang | MSVC | |
|---|---|---|---|
| Windows | MinGW | MinGW | + |
| Cygwin | - | - | N/A |
| MacOS | + | + | N/A |
| Linux | + | + | N/A |
The following compiler versions should be able to compile OpenXLSX without errors:
Clang 7 should be able to compile OpenXLSX, but apparently there is a bug in the implementation of std::variant, which causes compiler errors.
Visual Studio 2017 should also work, but hasn't been tested.
OpenXLSX uses CMake as the build system (or build system generator, to be exact) and git to pull in dependencies. Therefore, you must install CMake first, in order to build OpenXLSX. You can find (bad) installation instructions on www.cmake.org. If you wish the cmake to automatically fetch missing dependencies, you also need to install git.
Here is a summary to get a working configuration of cmake + git.
cmake & git on debian-based Linux distributionssudo apt update
sudo apt install build-essential cmake gitcmake & git on Windows 10/11 (for now only tested with MSYS Makefiles)Install MSYS2:
In a Powershell (run as Administrator): run winget install --id MSYS2.MSYS2 -e
→ After performing this step, the "MSYS2 MSYS shell" and the "MSYS2 MinGW 64-bit shell" should be accessible from the Start Menu
In MSYS2 MSYS shell: run pacman -Syu
The previous instruction might require a close & reopen of the MSYS2 MSYS shell
In MSYS2 MSYS shell: run pacman -Su
Install development toolchain:
In MSYS2 MinGW 64‑bit shell: run pacman -S --needed base-devel mingw-w64-x86_64-toolchain
Install cmake & git in MSYS2 environment:
pacman -S --needed mingw-w64-x86_64-cmake mingw-w64-x86_64-gitpacman -S --needed mingw-w64-x86_64-ninjaVerify installation:
In MSYS2 MinGW 64‑bit shell: verify versions of git, cmake, gcc, g++
git --version; cmake --version; gcc --version; g++ --versionIn MSYS2 MinGW 64‑bit shell
gitNo open issues yet, or sync has not completed.