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
Access to sheet by name
This example shows how to access to sheet by name instead by index.#include "libxl.h"
#include <iostream>
using namespace libxl;
Sheet* getSheetByName(Book* book, const wchar_t* name)
{
for(int i = 0; i < book->sheetCount(); ++i)
{
if(wcscmp(book->getSheet(i)->name(), name) == 0)
{
return book->getSheet(i);
}
}
return 0;
}
int main()
{
Book* book = xlCreateBook();
if(book->load(L"input.xls"))
{
Sheet* sheet = getSheetByName(book, L"Sheet2");
if(sheet)
{
double d = sheet->readNum(2, 2);
std::cout << d << std::endl;
}
else
{
std::cout << "Sheet not found" << std::endl;
}
}
book->release();
return 0;
}