OpenXLSX 1.9.1
Loading...
Searching...
No Matches
OpenXLSX::XLFilterColumn Class Reference

The XLFilterColumn class encapsulates the <filterColumn> XML node. It allows setting different kinds of filter criteria for a specific column in an AutoFilter range. More...

#include <XLAutoFilter.hpp>

Public Member Functions

 XLFilterColumn (XMLNode node)
 Constructor.
 
void addFilter (const std::string &value)
 Add a specific string value to filter by.
 
void clearFilters ()
 Clear all filters for this column.
 
void setCustomFilter (const std::string &op, const std::string &val)
 Set a single custom filter criteria.
 
void setCustomFilter (const std::string &op1, const std::string &val1, XLFilterLogic logic, const std::string &op2, const std::string &val2)
 Set a compound custom filter criteria.
 
void setTop10 (double value, bool percent=false, bool top=true)
 Set a top-10 filter.
 
void setDynamicFilter (const std::string &type)
 Set a dynamic filter (e.g. "aboveAverage", "today", "Q1").
 
uint16_t colId () const
 Get the column ID (0-based relative to the AutoFilter range).
 

Detailed Description

The XLFilterColumn class encapsulates the <filterColumn> XML node. It allows setting different kinds of filter criteria for a specific column in an AutoFilter range.

Constructor & Destructor Documentation

◆ XLFilterColumn()

OpenXLSX::XLFilterColumn::XLFilterColumn ( XMLNode  node)
explicit

Constructor.

Parameters
nodeThe <filterColumn> XMLNode

Member Function Documentation

◆ addFilter()

void OpenXLSX::XLFilterColumn::addFilter ( const std::string &  value)

Add a specific string value to filter by.

Parameters
valueThe value to add to the filter list.

◆ clearFilters()

void OpenXLSX::XLFilterColumn::clearFilters ( )

Clear all filters for this column.

◆ colId()

uint16_t OpenXLSX::XLFilterColumn::colId ( ) const

Get the column ID (0-based relative to the AutoFilter range).

Returns
The column ID.

◆ setCustomFilter() [1/2]

void OpenXLSX::XLFilterColumn::setCustomFilter ( const std::string &  op,
const std::string &  val 
)

Set a single custom filter criteria.

Parameters
opThe operator (e.g., "greaterThan", "lessThan", "equal", "notEqual", "greaterThanOrEqual", "lessThanOrEqual")
valThe value to compare against.

◆ setCustomFilter() [2/2]

void OpenXLSX::XLFilterColumn::setCustomFilter ( const std::string &  op1,
const std::string &  val1,
XLFilterLogic  logic,
const std::string &  op2,
const std::string &  val2 
)

Set a compound custom filter criteria.

Parameters
op1The first operator.
val1The first value.
logicThe logical operator joining the two conditions (And/Or).
op2The second operator.
val2The second value.

◆ setDynamicFilter()

void OpenXLSX::XLFilterColumn::setDynamicFilter ( const std::string &  type)

Set a dynamic filter (e.g. "aboveAverage", "today", "Q1").

Parameters
typeThe type of dynamic filter.

◆ setTop10()

void OpenXLSX::XLFilterColumn::setTop10 ( double  value,
bool  percent = false,
bool  top = true 
)

Set a top-10 filter.

Parameters
valueThe threshold value.
percentIf true, filters by top percentage rather than count.
topIf true, filters top values; if false, filters bottom values.

The documentation for this class was generated from the following files: