📊 Cross-platform user-friendly xlsx library for C++11+
Go to file
2016-08-06 10:40:17 -04:00
benchmarks start porting benchmarks 2016-02-06 10:04:41 -05:00
cmake cover time 2016-07-09 10:37:12 -04:00
docs work on docs 2016-07-21 23:25:24 -04:00
include/xlnt improve manifest, implement true thumbnail handling, being refactoring serialization tests 2016-08-06 10:40:17 -04:00
samples work on docs 2016-07-21 23:25:24 -04:00
source improve manifest, implement true thumbnail handling, being refactoring serialization tests 2016-08-06 10:40:17 -04:00
tests improve manifest, implement true thumbnail handling, being refactoring serialization tests 2016-08-06 10:40:17 -04:00
third-party clean up styles and hashing, add license boilerplate to all files, update readme, finish moving implementations to source files 2015-12-24 15:51:11 -05:00
.clang-format fix formatting 2016-01-17 22:23:31 -08: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 clean up styles and hashing, add license boilerplate to all files, update readme, finish moving implementations to source files 2015-12-24 15:51:11 -05:00
.travis.yml update travis build 2016-07-29 18:05:38 -04:00
appveyor.yml Update test location. 2016-07-05 11:41:41 +08:00
AUTHORS.md Update AUTHORS.md 2016-06-04 09:08:03 -06:00
CMakeLists.txt improve build 2016-01-16 21:07:02 -08:00
CONTRIBUTING.md improve documentation 2016-01-17 20:11:51 -08:00
LICENCE.md start moving all implementations to source files 2015-11-19 22:54:54 -05:00
README.md edit readme and see if forcing rebuild will make gcc5 compile successfully 2016-08-01 20:22:06 -04:00

xlnt

Travis Build Status AppVeyor Build status Coverage Status ReadTheDocs Documentation Status License

Introduction

xlnt is a C++14 library for reading, writing, and modifying XLSX files as described in ECMA 376. The API is based on openpyxl, a Python library to read/write Excel 2007 xlsx/xlsm files, and ultimately on PHPExcel, pure PHP library for reading and writing spreadsheet files upon which openpyxl was based. This project 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
// can also use the generated "xlnt.pc" in ./build directory with pkg-config to get these flags
#include <xlnt/xlnt.hpp>

Creating a new spreadsheet and saving it as book1.xlsx

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, book2.xlsx, and printing all cells

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

// no need to use references, "cell", "range", and "worksheet" classes 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 uses continous integration and passes all 300+ tests in GCC 4.9, VS2015, 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's cmake directory. A full list of cmake generators can be found here. A basic build would look like (starting in the root xlnt directory):

mkdir build
cd build
cmake ..
make -j8

The resulting library, libxlnt.dylib or libxlnt.so or xlnt.dll, would be found in the build/lib directory. Other cmake configuration options can be found using "cmake -LH". These options include shared vs static library and whether to build tests or not. An example of building a static library with tests as an Xcode project:

mkdir build
cd build
cmake -D TESTS=1 -D SHARED=0 -D STATIC=1 -G Xcode ..
cmake --build .
bin/xlnt.test

Dependencies

xlnt uses the following libraries, which are included in the source tree (all but miniz as git submodules) for convenience:

Initialize the submodules with this command:

git submodule update --init

Documentation

More extensive documentation with examples can be found on Read The Docs.

License

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

Copyright (c) 2015-2016 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.