Installation
Binaries
Provided binaries (v1.5.0) are rather old, it may be better to build from source at least until new binaries are available.
Arch
xlnt can be found on the AUR.
vcpkg
vcpkg
installs x86 by default
if you need x64 use the following command
Compiling from source
The latest xlnt version can be obtained by building xlnt from source (using the git master branch). All changes are reviewed and tested using CI before being added to the master branch.
Build configurations for Visual Studio, GNU Make, Ninja, and Xcode can be created using cmake v3.2+. A full list of cmake generators can be found here. A basic build would look like (starting in the root xlnt directory):
General
Install dependencies:
To build xlnt from source, you should install git, CMake and a C++ compiler.
Obtain the source files:
Latest source files can be obtained using git:
The --recurse-submodules
option is needed to download the third-party libstudxml dependency. If the repo was cloned without this option, libstudxml can be downloaded using the following command:
If you later want to update the source files to the latest version, you can run the following command:
Create build configuration
Build configuration is generated using CMake:
By default, xlnt is built as a shared library. Some important options are:
STATIC: Set to ON to build xlnt as a static library instead of a shared library.
TESTS: Set to ON to build test executable (in ./tests). Requires de_DE locale being installed on your system for all tests to succeed.
DOCUMENTATION: Set to ON to build API reference documentation (in ./api-reference). Requires doxygen being installed on your system.
CMAKE_INSTALL_PREFIX: specify the location where you want to install xlnt.
CMAKE_BUILD_TYPE: Specify the desired build type (Debug, Release, RelWithDebInfo or MinSizeRel). Only applicable for single-configuration generators (Makefile or Ninja), typically used on Linux derivatives (e.g. Ubuntu).
To build a static library including tests and documentation, you can use the following cmake command:
Other CMake configuration options for xlnt can be found using "cmake -LH".
Build
In case of a multi-configuration generators (e.g. Visual Studio and Xcode), you can specify the desired build type (e.g. Debug
or Release
):
Install
In case of a multi-configuration generators (e.g. Visual Studio and Xcode), it may be needed to specify the build type again (e.g. Debug
or Release
):
Example: Ubuntu 24.04 LTS (Noble Numbat)
Time required: Approximately 5 minutes (depending on your internet speed)
Install dependencies (CMake, C++ compiler):
The following steps will install xlnt
The following step will map the shared library names to the location of the corresponding shared library files
xlnt will now be ready to use on your Ubuntu instance.
Example: Xcode
Install git, CMake and Xcode.
Download the source code:
Generate the Xcode project:
Build the project:
The resulting shared (e.g. libxlnt.dylib) library would be found in the build/lib directory.
Example: Windows
Install git, CMake and Visual Studio.
Download the source code:
Generate the Visual Studio project file:
If desired, you can specify the Visual Studio version and architecture to use. To build a 64-bit library using Visual Studio 2019, use the following command:
Open the generated solution file xlnt_all.sln
(inside the build folder) using Visual Studio and build the INSTALL
project (or the ALL_BUILD
project if you don't want the install the library). The project will by default be installed in the installed
subdirectory of the build folder.
Using xlnt in your project
General
Use at least c++11 (e.g. -std=c++14)
Include
xlnt/xlnt.hpp
in your source file:
If xlnt is not installed in a default location, you may need to specify the include directory where the xlnt files may be found (e.g. -Ixlnt/include)
Link against the libxlnt library (e.g. -lxlnt).
See our REAMDE or Basic examples to get started with using xlnt.
Ensure the xlnt library is in your (library) path (if xlnt is built as a shared library and installed in a non-default location or on Windows):
On unix:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/custom/xlnt/install/directory
On Windows:
set PATH=%PATH%;c:\path\to\custom\xlnt\install\directory
Example: CMake project
Add the following lines to your CMakeLists.txt to use xlnt into your project:
with <target>
being replaced by the name of your target (see add_executable
).
If CMake could not find Xlnt (e.g. because you are building on Windows or installed xlnt in a non-default location, see CMAKE_INSTALL_PREFIX), you should specify the path where xlnt is installed:
When running, you should still make sure that the xlnt library is in your (library) path (if xlnt is built as a shared library): see the general instructions.
Last updated