Home Documentation Writing Reading Pictures1 Pictures2 Formulas DateTime SheetByName
Merging Grouping InsertRowCol NumFormats Formats Fonts Buffer1 Buffer2 Copying TopNFilter
Sorting StringFilter NumberFilter FilterByValues Protection Replacing RichString BeginWith
ColorScale OpRule AltRows
Merging Grouping InsertRowCol NumFormats Formats Fonts Buffer1 Buffer2 Copying TopNFilter
Sorting StringFilter NumberFilter FilterByValues Protection Replacing RichString BeginWith
ColorScale OpRule AltRows
Reading from memory buffer
This example shows how to read an Excel spreadsheet from memory buffer.#include "libxl.h"
#include <iostream>
#include <fstream>
using namespace libxl;
int main()
{
std::fstream stream("input.xls", std::ios_base::in | std::ios_base::binary);
if(!stream)
{
std::cout << "file not found" << std::endl;
return 1;
}
stream.seekg(0, std::ios_base::end);
unsigned size = stream.tellg();
char* buf = new char[size];
stream.seekg(0, std::ios_base::beg);
stream.read(buf, size);
Book* book = xlCreateBook();
if(book->loadRaw(buf, size))
{
Sheet* sheet = book->getSheet(0);
std::wcout << sheet->name() << std::endl;
}
else
{
std::cout << book->errorMessage() << std::endl;
return 1;
}
delete[] buf;
return 0;
}