Created
December 28, 2016 15:27
-
-
Save derofim/62a593305d603d3e7d8e3001eb80992e to your computer and use it in GitHub Desktop.
C++ excel example https://github.com/tfussell/xlnt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <xlnt/xlnt.hpp> | |
#include <iostream> | |
void create() { | |
xlnt::workbook wb; | |
xlnt::worksheet ws = wb.active_sheet(); | |
ws.cell("A1").value(5); | |
ws.cell("B2").value("string data"); | |
ws.cell("C3").formula("=RAND()"); | |
ws.merge_cells("C3:C4"); | |
ws.freeze_panes("B2"); | |
wb.save("sample.xlsx"); | |
} | |
void read() { | |
xlnt::workbook wb; | |
wb.load("sample.xlsx"); | |
xlnt::worksheet ws = wb.active_sheet(); | |
std::cout << ws.cell("A1") << std::endl; | |
std::cout << ws.cell("B2") << std::endl; | |
std::cout << ws.cell("C3") << std::endl; | |
} | |
int main() | |
{ | |
create(); | |
read(); | |
return 0; | |
} |
std::string ch = ws.cell("A1").value<std::string>();
double dh = ws.cell("A1").value<double>();
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
git clone https://github.com/tfussell/xlnt.git -b v0.9.1 --recurse-submodules
cd xlnt
mkdir build
cd build
cmake -D STATIC=ON -G "Visual Studio 14 2015 Win64" ..
cmake --build .