OpenXLSX 1.12.1
Modern C++ Excel Library (Fork of OpenXLSX by Kenneth Troldal Balslev)
Loading...
Searching...
No Matches
XLStyles_CellStyles.hpp
Go to the documentation of this file.
1/*
2 * OpenXLSX-NX - Modern High-Performance C++ Excel Library
3 *
4 * Original work Copyright (c) 2018-2025, Kenneth Troldal Balslev and OpenXLSX contributors
5 * Modified work Copyright (c) 2026, Curry Tang and OpenXLSX-NX contributors
6 *
7 * Distributed under the BSD 3-Clause License.
8 * See LICENSE.md in the project root or https://opensource.org/licenses/BSD-3-Clause
9 */
10
11#ifndef OPENXLSX_XLSTYLES_CELLSTYLES_HPP
12#define OPENXLSX_XLSTYLES_CELLSTYLES_HPP
13
14#ifdef _MSC_VER
15# pragma warning(push)
16# pragma warning(disable : 4251)
17# pragma warning(disable : 4275)
18#endif
19
20#include "XLStyles_Common.hpp"
21#include "XLXmlFile.hpp"
22#include "XLXmlParser.hpp"
23
24#include <memory>
25#include <string>
26#include <string_view>
27#include <vector>
28
29
30namespace OpenXLSX
31{
32 class OPENXLSX_EXPORT XLCellStyle
33 {
34 friend class XLCellStyles; // for access to m_cellStyleNode in XLCellStyles::create
35
36 public: // ---------- Public Member Functions ---------- //
41
46 explicit XLCellStyle(const XMLNode& node);
47
52 XLCellStyle(const XLCellStyle& other);
53
58 XLCellStyle(XLCellStyle&& other) noexcept = default;
59
64
70 XLCellStyle& operator=(const XLCellStyle& other);
71
77 XLCellStyle& operator=(XLCellStyle&& other) noexcept = default;
78
83 bool empty() const;
84
89 std::string name() const;
90
95 XLStyleIndex xfId() const;
96
102 uint32_t builtinId() const;
103
109 uint32_t outlineStyle() const;
110
115 bool hidden() const;
116
121 bool customBuiltin() const;
122
126 XLUnsupportedElement extLst() const { return XLUnsupportedElement{}; } // <cellStyle><extLst>...</extLst></cellStyle>
127
133 bool setName(std::string_view newName);
134 bool setXfId(XLStyleIndex newXfId);
135 bool setBuiltinId(uint32_t newBuiltinId);
136 bool setOutlineStyle(uint32_t newOutlineStyle);
137 bool setHidden(bool set = true);
138 bool setCustomBuiltin(bool set = true);
142 bool setExtLst(XLUnsupportedElement const& newExtLst);
143
148 std::string summary() const;
149
150 private: // ---------- Private Member Variables ---------- //
151 std::unique_ptr<XMLNode> m_cellStyleNode;
152 };
153
157 class OPENXLSX_EXPORT XLCellStyles
158 {
159 public: // ---------- Public Member Functions ---------- //
163 XLCellStyles();
164
169 explicit XLCellStyles(const XMLNode& node);
170
175 XLCellStyles(const XLCellStyles& other);
176
181 XLCellStyles(XLCellStyles&& other);
182
187
193 XLCellStyles& operator=(const XLCellStyles& other);
194
200 XLCellStyles& operator=(XLCellStyles&& other) noexcept = default;
201
206 size_t count() const;
207
213
219 XLCellStyle operator[](XLStyleIndex index) const { return cellStyleByIndex(index); }
220
227 XLStyleIndex create(XLCellStyle copyFrom = XLCellStyle{}, std::string_view styleEntriesPrefix = XLDefaultStyleEntriesPrefix);
228
229 private: // ---------- Private Member Variables ---------- //
230 std::unique_ptr<XMLNode> m_cellStylesNode;
231 std::vector<XLCellStyle> m_cellStyles;
232 };
233
234} // namespace OpenXLSX
235
236#ifdef _MSC_VER
237# pragma warning(pop)
238#endif
239
240#endif // OPENXLSX_XLSTYLES_CELLSTYLES_HPP
Definition XLStyles_CellStyles.hpp:33
XLCellStyle & operator=(const XLCellStyle &other)
Copy assignment operator.
Definition XLStyles_CellStyles.cpp:39
bool hidden() const
Get the hidden flag of the cell style.
Definition XLStyles_CellStyles.cpp:51
friend class XLCellStyles
Definition XLStyles_CellStyles.hpp:34
uint32_t builtinId() const
Get the built-in id of the cell style.
Definition XLStyles_CellStyles.cpp:49
XLCellStyle()
Definition XLStyles_CellStyles.cpp:31
bool customBuiltin() const
Get the custom buildin flag.
Definition XLStyles_CellStyles.cpp:52
std::string name() const
Get the name of the cell style.
Definition XLStyles_CellStyles.cpp:47
bool empty() const
Test if this is an empty node.
Definition XLStyles_CellStyles.cpp:45
uint32_t outlineStyle() const
Get the outline style id (attribute iLevel) of the cell style.
Definition XLStyles_CellStyles.cpp:50
XLStyleIndex xfId() const
Get the id of the cell style format.
Definition XLStyles_CellStyles.cpp:48
XLUnsupportedElement extLst() const
Unsupported getter.
Definition XLStyles_CellStyles.hpp:126
XLCellStyle & operator=(XLCellStyle &&other) noexcept=default
Move assignment operator.
XLCellStyle(XLCellStyle &&other) noexcept=default
Move Constructor.
XLCellStyles & operator=(XLCellStyles &&other) noexcept=default
Move assignment operator.
XLCellStyle cellStyleByIndex(XLStyleIndex index) const
Get the cell style identified by index.
Definition XLStyles_CellStyles.cpp:130
size_t count() const
Get the count of cell styles.
Definition XLStyles_CellStyles.cpp:128
XLCellStyle operator[](XLStyleIndex index) const
Operator overload: allow [] as shortcut access to cellStyleByIndex.
Definition XLStyles_CellStyles.hpp:219
XLCellStyles()
Definition XLStyles_CellStyles.cpp:90
XLCellStyles & operator=(const XLCellStyles &other)
Copy assignment operator.
Definition XLStyles_CellStyles.cpp:118
The XLUnsupportedElement class provides a stub implementation that can be used as function parameter ...
Definition XLXmlFile.hpp:42
Definition IXLCellProvider.hpp:24
OpenXLSX_xml_node XMLNode
Definition XLXmlParser.hpp:64
size_t XLStyleIndex
Definition XLStyles_Common.hpp:36