OpenXLSX 1.9.1
Loading...
Searching...
No Matches
XLAutoFilter.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "XLXmlParser.hpp"
4#include <string>
5
6namespace OpenXLSX
7{
8
12 enum class XLFilterLogic { And, Or };
13
19 {
20 public:
25 explicit XLFilterColumn(XMLNode node);
26
31 void addFilter(const std::string& value);
32
36 void clearFilters();
37
43 void setCustomFilter(const std::string& op, const std::string& val);
44
53 void setCustomFilter(const std::string& op1,
54 const std::string& val1,
55 XLFilterLogic logic,
56 const std::string& op2,
57 const std::string& val2);
58
65 void setTop10(double value, bool percent = false, bool top = true);
66
71 void setDynamicFilter(const std::string& type);
72
77 uint16_t colId() const;
78
79 private:
80 XMLNode m_node;
81 };
82
87 class XLCellRange;
88
90 {
91 public:
96 explicit XLAutoFilter(XMLNode node);
97
102 operator bool() const;
103
108 std::string ref() const;
109
114 XLAutoFilter& setRef(const std::string& ref);
115
120 XLAutoFilter& setRef(const XLCellRange& range);
121
127 XLFilterColumn filterColumn(uint16_t colId);
128
129 private:
130 XMLNode m_node;
131 };
132
133} // namespace OpenXLSX
Definition XLXmlParser.hpp:84
Definition XLAutoFilter.hpp:90
XLFilterColumn filterColumn(uint16_t colId)
Get or create a filter column by its ID.
Definition XLAutoFilter.cpp:131
XLAutoFilter & setRef(const std::string &ref)
Set the reference range of the AutoFilter.
Definition XLAutoFilter.cpp:118
std::string ref() const
Get the reference range of the AutoFilter.
Definition XLAutoFilter.cpp:112
Represents a rectangular area of cells within a worksheet.
Definition XLCellRange.hpp:30
The XLFilterColumn class encapsulates the <filterColumn> XML node. It allows setting different kinds ...
Definition XLAutoFilter.hpp:19
void clearFilters()
Clear all filters for this column.
Definition XLAutoFilter.cpp:31
void setCustomFilter(const std::string &op, const std::string &val)
Set a single custom filter criteria.
Definition XLAutoFilter.cpp:42
void setTop10(double value, bool percent=false, bool top=true)
Set a top-10 filter.
Definition XLAutoFilter.cpp:76
uint16_t colId() const
Get the column ID (0-based relative to the AutoFilter range).
Definition XLAutoFilter.cpp:100
void setDynamicFilter(const std::string &type)
Set a dynamic filter (e.g. "aboveAverage", "today", "Q1").
Definition XLAutoFilter.cpp:90
void addFilter(const std::string &value)
Add a specific string value to filter by.
Definition XLAutoFilter.cpp:12
Definition IZipArchive.hpp:18
XLFilterLogic
Enum class defining the logical operator for custom filters.
Definition XLAutoFilter.hpp:12