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
AutoFilter: string custom filter
The FilterColumn::setCustomFilter() method sets the custom filter in AutoFilter:#include "libxl.h" using namespace libxl; int main() { Book* book = xlCreateXMLBook(); Sheet* sheet = book->addSheet(L"my"); sheet->writeStr(2, 1, L"Country"); sheet->writeStr(2, 2, L"Road injures"); sheet->writeStr(2, 3, L"Smoking"); sheet->writeStr(2, 4, L"Suicide"); sheet->writeStr(3, 1, L"USA"); sheet->writeStr(4, 1, L"UK"); sheet->writeNum(3, 2, 64); sheet->writeNum(4, 2, 94); sheet->writeNum(3, 3, 69); sheet->writeNum(4, 3, 55); sheet->writeNum(3, 4, 49); sheet->writeNum(4, 4, 64); sheet->writeStr(5, 1, L"Germany"); sheet->writeStr(6, 1, L"Switzerland"); sheet->writeNum(5, 2, 88); sheet->writeNum(6, 2, 93); sheet->writeNum(5, 3, 46); sheet->writeNum(6, 3, 54); sheet->writeNum(5, 4, 55); sheet->writeNum(6, 4, 50); sheet->writeStr(7, 1, L"Spain"); sheet->writeStr(8, 1, L"Italy"); sheet->writeNum(7, 2, 86); sheet->writeNum(8, 2, 75); sheet->writeNum(7, 3, 47); sheet->writeNum(8, 3, 52); sheet->writeNum(7, 4, 69); sheet->writeNum(8, 4, 71); sheet->writeStr(9, 1, L"Greece"); sheet->writeStr(10, 1, L"Japan"); sheet->writeNum(9, 2, 67); sheet->writeNum(10, 2, 91); sheet->writeNum(9, 3, 23); sheet->writeNum(10, 3, 57); sheet->writeNum(9, 4, 87); sheet->writeNum(10, 4, 36); AutoFilter* autoFilter = sheet->autoFilter(); autoFilter->setRef(2, 10, 1, 4); // shows all countries with the first letter G FilterColumn* column = autoFilter->column(0); column->setCustomFilter(OPERATOR_EQUAL, L"G*"); sheet->applyFilter(); book->save(L"out.xlsx"); book->release(); return 0; }
See also other AutoFilter examples: Top N number of items to filter by
Sorting
Number custom filter
Filter by values