2014-05-07 05:28:38 +08:00
xlnt
====
2014-05-20 08:52:04 +08:00
## Introduction
2014-05-20 09:54:34 +08:00
xlnt is a c++ library for reading, writing, and modifying xlsx files. The API is roughly 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.
2014-05-07 05:28:38 +08:00
2014-05-20 08:52:04 +08:00
## Usage
Including xlnt in your project
2014-05-20 05:37:00 +08:00
```c++
#include <xlnt.h>
```
2014-05-20 08:52:04 +08:00
Creating a new spreadsheet and saving it
2014-05-20 05:34:35 +08:00
```c++
xlnt::workbook wb;
xlnt::worksheet ws = wb.get_active_sheet();
ws.cell("A1") = 5;
ws.cell("B2") = "string data";
ws.cell("C3") = "=RAND()";
ws.merge_cells("C3:C4");
ws.freeze_panes("B2");
wb.save("book1.xlsx");
2014-05-20 05:35:24 +08:00
```
2014-05-20 05:34:35 +08:00
2014-05-20 08:52:04 +08:00
Opening an existing spreadsheet and printing all rows
2014-05-20 05:35:24 +08:00
```c++
2014-05-20 05:34:35 +08:00
xlnt::workbook wb2;
wb2.load("book2.xlsx");
wb2["sheet1"].get_dimensions();
for(auto & row : wb2["sheet2"])
{
for(auto cell : row)
{
std::cout < < cell.to_string ( ) < < std::endl ;
}
}
```
2014-05-20 08:52:04 +08:00
## Building
xlnt is regularly built and passes all 200+ tests in GCC 4.8.2, MSVC 12, and Clang 3.3.
2014-05-07 05:28:38 +08:00
2014-05-20 08:52:04 +08:00
Workspaces for Visual Studio 2013, and GNU Make can be created using premake and the premake5.lua file in the build directory (requires premake5, currently available [here ](https://bitbucket.org/premake/premake-dev )).
2014-05-07 05:28:38 +08:00
2014-05-20 08:52:04 +08:00
## Dependencies
2014-05-07 05:28:38 +08:00
xlnt requires the following libraries:
2014-05-20 05:34:35 +08:00
- [zlib v1.2.8 ](http://zlib.net/ ) (zlib/libpng license)
- [pugixml v1.4 ](http://pugixml.org/ ) (MIT license)
2014-05-07 05:28:38 +08:00
2014-05-20 08:52:04 +08:00
## License
xlnt is currently released to the public for free under the terms of the MIT License:
2014-05-20 05:34:35 +08:00
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.