Skip to content

Instantly share code, notes, and snippets.

@derofim
Created December 28, 2016 15:27
Show Gist options
  • Save derofim/62a593305d603d3e7d8e3001eb80992e to your computer and use it in GitHub Desktop.
Save derofim/62a593305d603d3e7d8e3001eb80992e to your computer and use it in GitHub Desktop.
#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;
}
@derofim
Copy link
Author

derofim commented Dec 28, 2016

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 .

@derofim
Copy link
Author

derofim commented Dec 28, 2016

image

@derofim
Copy link
Author

derofim commented Dec 28, 2016

image

@derofim
Copy link
Author

derofim commented Dec 28, 2016

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