📊 Cross-platform user-friendly xlsx library for C++11+
Go to file
2015-10-12 17:30:00 -04:00
build update copyright, add overloads for all int sizes, fix line ending in zip_file test 2015-10-01 18:14:42 -04:00
docs/samples 1000 by 1000 is a bit extreme 2015-09-29 00:31:37 -04:00
include/xlnt fix precision on time to number, fix type guessing, fix long long on osx 2015-10-06 12:31:49 -04:00
scripts continue synchronizing tests and start implementing styles 2014-07-26 16:19:15 -04:00
source fix precision on time to number, fix type guessing, fix long long on osx 2015-10-06 12:31:49 -04:00
tests fix precision on time to number, fix type guessing, fix long long on osx 2015-10-06 12:31:49 -04:00
third-party miniz archive type is forward declared so move include into zip_file.cpp where it's needed 2015-09-29 00:38:00 -04:00
.clang-format initial commit 2014-05-06 17:28:38 -04:00
.gitattributes initial commit 2014-05-06 17:28:38 -04:00
.gitignore ignore autogenerated file 2015-10-01 18:38:14 -04:00
.gitmodules remove zlib 2014-08-01 12:01:15 -04:00
README.md Premake moved to github 2015-10-12 17:30:00 -04:00

xlnt

Introduction

xlnt is a C++11 library for reading, writing, and modifying xlsx files. The API is generally based on openpyxl, a python library for reading and writing xlsx/xlsm files. It is still very much a work in progress, but the core development work is complete.

Usage

Including xlnt in your project

// with -Ixlnt/include
#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.get_value().to_string() << std::endl;
    }
}

Building

xlnt is regularly built and passes all 200+ tests in GCC 4.8.2, MSVC 12, and Clang 3.4.

Workspaces for Visual Studio 2013, and GNU Make can be created using the development version of premake (currently available here and the premake5.lua script in the build directory. XCode workspaces can be generated using premake4.lua and premake4 (binaries here).

In Windows, with Visual Studio 2013:

cd build
premake5 vs2013
start vs2013/xlnt.sln

In Linux, with GCC 4.8:

cd build
premake5 gmake
cd gmake
make

In OSX, with Clang 3.4 (can also use gmake as described above):

cd build
premake4 xcode4
open xcode4/xlnt.xcworkspace

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.