📊 Cross-platform user-friendly xlsx library for C++11+
Go to file
2015-11-03 08:46:40 -05:00
cmake restructure source and clean up cmake scripts 2015-11-03 08:38:09 -05:00
docs update docs 2015-10-31 06:47:38 -04:00
include/xlnt add missing runtime_error include and improperly located headers 2015-11-03 08:46:40 -05:00
samples update readme and fix samples 2015-11-02 00:29:39 -05:00
source add missing runtime_error include and improperly located headers 2015-11-03 08:46:40 -05:00
tests add missing runtime_error include and improperly located headers 2015-11-03 08:46:40 -05:00
third-party work on writer 2015-10-14 18:05:13 -04:00
.clang-format clang-format all files, update .clang-format, fix minor compilation errors 2015-11-01 09:43:01 -05:00
.gitattributes initial commit 2014-05-06 17:28:38 -04:00
.gitignore fix all tests 2015-11-01 23:52:19 -05:00
.gitmodules remove zlib 2014-08-01 12:01:15 -04:00
.travis.yml fix travis build 2015-11-01 23:54:38 -05:00
clean fix permissions on build scripts 2015-11-02 15:20:48 -05:00
clean.bat fix windows errors 2015-11-02 14:22:13 -05:00
configure fix windows build and warnings 2015-11-02 17:25:10 -05:00
configure.bat fix windows errors 2015-11-02 14:22:13 -05:00
README.md update readme and fix samples 2015-11-02 00:29:39 -05:00

xlnt

Build Status

Introduction

xlnt is a C++14 library for reading, writing, and modifying XLSX files as described in ECMA 376. The API is roughly based on openpyxl, a python library for reading and writing xlsx/xlsm files. This is still very much a work in progress, but the core development work is complete.

Usage

Including xlnt in your project

// with -std=c++14 -Ixlnt/include -Lxlnt/lib -lxlnt
#include <xlnt/xlnt.hpp>

Creating a new spreadsheet and saving it

xlnt::workbook wb;
xlnt::worksheet ws = wb.get_active_sheet();
ws.get_cell("A1").set_value(5);
ws.get_cell("B2").set_value("string data");
ws.get_cell("C3").set_formula("=RAND()");
ws.merge_cells("C3:C4");
ws.freeze_panes("B2");
wb.save("book1.xlsx");

Opening an existing spreadsheet and printing all rows

xlnt::workbook wb2;
wb2.load("book2.xlsx");

// no need to use references, iterators are only wrappers around pointers to memory in the workbook
for(auto row : wb2["sheet2"].rows())
{
    for(auto cell : row)
    {
        std::cout << cell << std::endl;
    }
}

Building

xlnt is regularly built and passes all 200+ tests in GCC 4.8.2, MSVC 14, and Clang (using Apple LLVM 7.0).

Build configurations for Visual Studio 2015, GNU Make, and Xcode can be created using cmake and the cmake scripts in the project directory, cmake.

In OSX, with Xcode:

mkdir build
cd build
cmake -G Xcode ../cmake
open xlnt.xcproject

In Windows, with Visual Studio 2015:

mkdir build
cd build
cmake -G "Visual Studio 14 2015" ../cmake
start xlnt.sln

In Linux or OSX, with GNU Make:

mkdir build
cd build
cmake -G "Unix Makefiles" ../cmake
make

Dependencies

xlnt uses the following libraries, which are included in the source tree (pugixml and cxxtest as git submodules) for convenience:

License

xlnt is currently released to the public for free under the terms of the MIT License:

Copyright (c) 2014 Thomas Fussell

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.