OpenXLSX 1.12.1
Modern C++ Excel Library (Fork of OpenXLSX by Kenneth Troldal Balslev)
Loading...
Searching...
No Matches
XLColumn.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_XLCOLUMN_HPP
12#define OPENXLSX_XLCOLUMN_HPP
13
14#ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
15# pragma warning(push)
16# pragma warning(disable : 4251)
17# pragma warning(disable : 4275)
18#endif // _MSC_VER
19
20// ===== External Includes ===== //
21#include <memory>
22
23// ===== OpenXLSX Includes ===== //
24#include "OpenXLSX-Exports.hpp"
25#include "XLStyles_Common.hpp" // XLStyleIndex, XLDefaultCellFormat
26#include "XLXmlParser.hpp"
27#include "XLXmlSchema.hpp"
28
29namespace OpenXLSX
30{
34 class OPENXLSX_EXPORT XLColumn
35 {
36 public:
41 explicit XLColumn(XMLNode columnNode);
42
47 float width() const;
48
53 void setWidth(float width);
54
59 void autoFit();
60
65 bool isHidden() const;
66
71 void setHidden(bool state);
72
77 uint8_t outlineLevel() const;
78
83 void setOutlineLevel(uint8_t level);
84
89 bool isCollapsed() const;
90
95 void setCollapsed(bool state);
96
101 XMLNode columnNode() const;
102
108 XLStyleIndex format() const;
109
115 bool setFormat(XLStyleIndex cellFormatIndex);
116
120 [[nodiscard]] XLColumnProperties properties() const;
121
125 void setProperties(const XLColumnProperties& props);
126
127 private:
133 XMLAttribute getOrCreateAttribute(const char* attrName);
134
135 XMLNode m_columnNode;
136 };
137
138} // namespace OpenXLSX
139
140#ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
141# pragma warning(pop)
142#endif // _MSC_VER
143
144#endif // OPENXLSX_XLCOLUMN_HPP
bool isCollapsed() const
Is the column collapsed?
Definition XLColumn.cpp:87
uint8_t outlineLevel() const
Get the outline level of the column.
Definition XLColumn.cpp:66
XLColumn(XMLNode columnNode)
Constructor.
Definition XLColumn.cpp:25
void setCollapsed(bool state)
Set the column to be collapsed or expanded.
Definition XLColumn.cpp:92
float width() const
Get the width of the column.
Definition XLColumn.cpp:35
void setWidth(float width)
Set the width of the column.
Definition XLColumn.cpp:40
void setProperties(const XLColumnProperties &props)
Set all column properties from a value-semantic POD struct in a single pass.
Definition XLColumn.cpp:126
XMLNode columnNode() const
Get the XMLNode object for the column.
Definition XLColumn.cpp:104
XLStyleIndex format() const
Get the array index of xl/styles.xml:<styleSheet>:<cellXfs> for the style assigned to the column....
Definition XLColumn.cpp:109
bool setFormat(XLStyleIndex cellFormatIndex)
Set the column style as a reference to the array index of xl/styles.xml:<styleSheet>:<cellXfs>.
Definition XLColumn.cpp:115
XLColumnProperties properties() const
Get the column properties as a value-semantic POD struct.
Definition XLColumn.cpp:121
bool isHidden() const
Is the column hidden?
Definition XLColumn.cpp:49
void autoFit()
Auto fit the column width based on the content of its cells.
Definition XLColumn.cpp:131
void setOutlineLevel(uint8_t level)
Set the outline level of the column.
Definition XLColumn.cpp:74
void setHidden(bool state)
Set the column to be shown or hidden.
Definition XLColumn.cpp:54
Definition XLXmlParser.hpp:283
Definition IXLCellProvider.hpp:24
OpenXLSX_xml_node XMLNode
Definition XLXmlParser.hpp:64
size_t XLStyleIndex
Definition XLStyles_Common.hpp:36
Plain POD properties describing an OOXML Column (<col> element).
Definition XLXmlSchema.hpp:191