OpenXLSX 1.12.1
Modern C++ Excel Library (Fork of OpenXLSX by Kenneth Troldal Balslev)
Loading...
Searching...
No Matches
XLStyles_Common.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_COMMON_HPP
12#define OPENXLSX_XLSTYLES_COMMON_HPP
13
14#ifdef _MSC_VER
15# pragma warning(push)
16# pragma warning(disable : 4251)
17# pragma warning(disable : 4275)
18#endif
19
20// ===== External Includes ===== //
21#include <cstddef>
22#include <cstdint>
23#include <string>
24#include <string_view>
25
26// ===== OpenXLSX Includes ===== //
27#include "OpenXLSX-Exports.hpp"
28
29namespace OpenXLSX
30{
31 using namespace std::literals::string_view_literals; // enables sv suffix only
32
33 // Forward declaration to avoid circular includes (XLStyle.hpp uses enums from this header)
34 struct XLStyle;
35
36 using XLStyleIndex = size_t; // custom data type for XLStyleIndex
37
38 constexpr const uint32_t XLInvalidUInt16 = 0xffff; // used to signal "value not defined" for uint16_t return types
39 constexpr const uint32_t XLInvalidUInt32 = 0xffffffff; // used to signal "value not defined" for uint32_t return types
40 constexpr const uint32_t XLDeleteProperty = XLInvalidUInt32; // when 0 or "" is not the same as "property does not exist", this value
41 // // can be passed to setter functions to delete the property from XML
42 // // currently supported in: XLDataBarColor::setTheme
43
44 constexpr const bool XLPermitXfID = true; // use with XLCellFormat constructor to enable xfId() getter and setXfId() setter
45
46 constexpr const bool XLCreateIfMissing = true; // use with XLCellFormat::alignment(XLCreateIfMissing)
47 constexpr const bool XLDoNotCreate = false; // use with XLCellFormat::alignment(XLDoNotCreate)
48
49 constexpr const bool XLForceFillType = true;
50
51 constexpr const char* XLDefaultStylesPrefix = "\n\t"; // indentation to use for newly created root level style node tags
52 constexpr const char* XLDefaultStyleEntriesPrefix = "\n\t\t"; // indentation to use for newly created style entry nodes
53
54 constexpr const XLStyleIndex XLDefaultCellFormat = 0; // default cell format index in xl/styles.xml:<styleSheet>:<cellXfs>
55
56 // ===== As pugixml attributes are not guaranteed to support value range of XLStyleIndex, use 32 bit unsigned int
57 constexpr const XLStyleIndex XLInvalidStyleIndex = XLInvalidUInt32; // as a function return value, indicates no valid index
58
59 constexpr const uint32_t XLDefaultFontSize = 12; //
60 constexpr const char* XLDefaultFontColor = "ff000000"; // default font color
61 constexpr const char* XLDefaultFontColorTheme = ""; // Theme color ID from theme1.xml (e.g., "1" for dark1)
62 constexpr const char* XLDefaultFontName = "Arial"; //
63 constexpr const uint32_t XLDefaultFontFamily = 0; // Font Family (0 = N/A, 1 = Roman, 2 = Swiss, 3 = Modern)
64 constexpr const uint32_t XLDefaultFontCharset = 1; // Character set (0 = ANSI, 1 = Default, 2 = Symbol)
65
66 constexpr const char* XLDefaultLineStyle = ""; // empty string = line not set
67
68 // Forward declarations of styles subdomain classes (defined in XLStyles_*.hpp)
69 class XLNumberFormat;
70 class XLNumberFormats;
71 class XLFont;
72 class XLFonts;
73 class XLDataBarColor;
74 class XLFill;
75 class XLFills;
76 class XLLine;
77 class XLBorder;
78 class XLBorders;
79 class XLAlignment;
80 class XLCellFormat;
81 class XLCellFormats;
82 class XLCellStyle;
83 class XLCellStyles;
84 class XLDxf;
85 class XLDxfs;
86 class XLStyles;
87
96
97 enum XLFontSchemeStyle : uint8_t {
98 XLFontSchemeNone = 0, // <scheme val="none"/>
99 XLFontSchemeMajor = 1, // <scheme val="major"/>
100 XLFontSchemeMinor = 2, // <scheme val="minor"/>
101 XLFontSchemeInvalid = 255 // all other values
102 };
103
104 enum XLVerticalAlignRunStyle : uint8_t {
105 XLBaseline = 0, // <vertAlign val="baseline"/>
106 XLSubscript = 1, // <vertAlign val="subscript"/>
107 XLSuperscript = 2, // <vertAlign val="superscript"/>
109 };
110
111 enum XLFillType : uint8_t {
112 XLGradientFill = 0, // <gradientFill />
113 XLPatternFill = 1, // <patternFill />
114 XLFillTypeInvalid = 255, // any child of <fill> that is not one of the above
115 };
116
118
119 enum XLPatternType : uint8_t {
120 XLPatternNone = 0, // "none"
121 XLPatternSolid = 1, // "solid"
122 XLPatternMediumGray = 2, // "mediumGray"
123 XLPatternDarkGray = 3, // "darkGray"
124 XLPatternLightGray = 4, // "lightGray"
125 XLPatternDarkHorizontal = 5, // "darkHorizontal"
126 XLPatternDarkVertical = 6, // "darkVertical"
127 XLPatternDarkDown = 7, // "darkDown"
128 XLPatternDarkUp = 8, // "darkUp"
129 XLPatternDarkGrid = 9, // "darkGrid"
130 XLPatternDarkTrellis = 10, // "darkTrellis"
131 XLPatternLightHorizontal = 11, // "lightHorizontal"
132 XLPatternLightVertical = 12, // "lightVertical"
133 XLPatternLightDown = 13, // "lightDown"
134 XLPatternLightUp = 14, // "lightUp"
135 XLPatternLightGrid = 15, // "lightGrid"
136 XLPatternLightTrellis = 16, // "lightTrellis"
137 XLPatternGray125 = 17, // "gray125"
138 XLPatternGray0625 = 18, // "gray0625"
139 XLPatternTypeInvalid = 255 // any patternType that is not one of the above
140 };
141 constexpr const XLFillType XLDefaultFillType = XLPatternFill; // node name for the pattern description is derived from this
142 constexpr const XLPatternType XLDefaultPatternType = XLPatternNone; // attribute patternType default value: no fill
143 constexpr const char* XLDefaultPatternFgColor = "ffffffff"; // child node fgcolor attribute rgb value
144 constexpr const char* XLDefaultPatternBgColor = "ff000000"; // child node bgcolor attribute rgb value
145
156
174
175 enum XLAlignmentStyle : uint8_t {
176 XLAlignGeneral = 0, // value="general", horizontal only
177 XLAlignLeft = 1, // value="left", horizontal only
178 XLAlignRight = 2, // value="right", horizontal only
179 XLAlignCenter = 3, // value="center", both
180 XLAlignTop = 4, // value="top", vertical only
181 XLAlignBottom = 5, // value="bottom", vertical only
182 XLAlignFill = 6, // value="fill", horizontal only
183 XLAlignJustify = 7, // value="justify", both
184 XLAlignCenterContinuous = 8, // value="centerContinuous", horizontal only
185 XLAlignDistributed = 9, // value="distributed", both
186 XLAlignInvalid = 255 // all other values
187 };
188
190} // namespace OpenXLSX
191
192#ifdef _MSC_VER
193# pragma warning(pop)
194#endif
195
196#endif // OPENXLSX_XLSTYLES_COMMON_HPP
Definition XLStyles_CellFormats.hpp:34
An encapsulation of a border item.
Definition XLStyles_Borders.hpp:114
An encapsulation of the XLSX borders.
Definition XLStyles_Borders.hpp:254
An encapsulation of a cell format item.
Definition XLStyles_CellFormats.hpp:174
An encapsulation of the XLSX cell style formats.
Definition XLStyles_CellFormats.hpp:375
Definition XLStyles_CellStyles.hpp:33
An encapsulation of the XLSX cell styles.
Definition XLStyles_CellStyles.hpp:158
Definition XLStyles_Fills.hpp:34
Definition XLStyles_Dxfs.hpp:36
An encapsulation of the XLSX differential cell formats (dxfs).
Definition XLStyles_Dxfs.hpp:151
An encapsulation of a fill item.
Definition XLStyles_Fills.hpp:282
An encapsulation of the XLSX fills.
Definition XLStyles_Fills.hpp:417
Definition XLStyles_Fonts.hpp:34
An encapsulation of the XLSX fonts.
Definition XLStyles_Fonts.hpp:205
Definition XLStyles_Borders.hpp:35
Definition XLStyles_NumberFormats.hpp:35
An encapsulation of the XLSX number formats (numFmts).
Definition XLStyles_NumberFormats.hpp:114
An encapsulation of the styles file (xl/styles.xml) in an Excel document package.
Definition XLStyles.hpp:50
Definition IXLCellProvider.hpp:24
XLFillType
Definition XLStyles_Common.hpp:111
@ XLPatternFill
Definition XLStyles_Common.hpp:113
@ XLGradientFill
Definition XLStyles_Common.hpp:112
@ XLFillTypeInvalid
Definition XLStyles_Common.hpp:114
XLAlignmentStyle
Definition XLStyles_Common.hpp:175
@ XLAlignInvalid
Definition XLStyles_Common.hpp:186
@ XLAlignRight
Definition XLStyles_Common.hpp:178
@ XLAlignBottom
Definition XLStyles_Common.hpp:181
@ XLAlignLeft
Definition XLStyles_Common.hpp:177
@ XLAlignCenterContinuous
Definition XLStyles_Common.hpp:184
@ XLAlignGeneral
Definition XLStyles_Common.hpp:176
@ XLAlignJustify
Definition XLStyles_Common.hpp:183
@ XLAlignFill
Definition XLStyles_Common.hpp:182
@ XLAlignDistributed
Definition XLStyles_Common.hpp:185
@ XLAlignCenter
Definition XLStyles_Common.hpp:179
@ XLAlignTop
Definition XLStyles_Common.hpp:180
XLLineType
Definition XLStyles_Common.hpp:146
@ XLLineLeft
Definition XLStyles_Common.hpp:147
@ XLLineBottom
Definition XLStyles_Common.hpp:150
@ XLLineVertical
Definition XLStyles_Common.hpp:152
@ XLLineDiagonal
Definition XLStyles_Common.hpp:151
@ XLLineRight
Definition XLStyles_Common.hpp:148
@ XLLineHorizontal
Definition XLStyles_Common.hpp:153
@ XLLineInvalid
Definition XLStyles_Common.hpp:154
@ XLLineTop
Definition XLStyles_Common.hpp:149
XLPatternType
Definition XLStyles_Common.hpp:119
@ XLPatternNone
Definition XLStyles_Common.hpp:120
@ XLPatternLightDown
Definition XLStyles_Common.hpp:133
@ XLPatternGray0625
Definition XLStyles_Common.hpp:138
@ XLPatternDarkGray
Definition XLStyles_Common.hpp:123
@ XLPatternTypeInvalid
Definition XLStyles_Common.hpp:139
@ XLPatternLightHorizontal
Definition XLStyles_Common.hpp:131
@ XLPatternDarkDown
Definition XLStyles_Common.hpp:127
@ XLPatternDarkHorizontal
Definition XLStyles_Common.hpp:125
@ XLPatternSolid
Definition XLStyles_Common.hpp:121
@ XLPatternDarkUp
Definition XLStyles_Common.hpp:128
@ XLPatternDarkGrid
Definition XLStyles_Common.hpp:129
@ XLPatternGray125
Definition XLStyles_Common.hpp:137
@ XLPatternLightVertical
Definition XLStyles_Common.hpp:132
@ XLPatternLightUp
Definition XLStyles_Common.hpp:134
@ XLPatternDarkTrellis
Definition XLStyles_Common.hpp:130
@ XLPatternDarkVertical
Definition XLStyles_Common.hpp:126
@ XLPatternLightGray
Definition XLStyles_Common.hpp:124
@ XLPatternLightGrid
Definition XLStyles_Common.hpp:135
@ XLPatternLightTrellis
Definition XLStyles_Common.hpp:136
@ XLPatternMediumGray
Definition XLStyles_Common.hpp:122
XLUnderlineStyle
Definition XLStyles_Common.hpp:88
@ XLUnderlineSingleAccounting
Definition XLStyles_Common.hpp:92
@ XLUnderlineDoubleAccounting
Definition XLStyles_Common.hpp:93
@ XLUnderlineSingle
Definition XLStyles_Common.hpp:90
@ XLUnderlineNone
Definition XLStyles_Common.hpp:89
@ XLUnderlineInvalid
Definition XLStyles_Common.hpp:94
@ XLUnderlineDouble
Definition XLStyles_Common.hpp:91
constexpr const char * XLDefaultPatternBgColor
Definition XLStyles_Common.hpp:144
constexpr const uint32_t XLDefaultFontSize
Definition XLStyles_Common.hpp:59
XLGradientType
Definition XLStyles_Common.hpp:117
@ XLGradientLinear
Definition XLStyles_Common.hpp:117
@ XLGradientTypeInvalid
Definition XLStyles_Common.hpp:117
@ XLGradientPath
Definition XLStyles_Common.hpp:117
constexpr const char * XLDefaultLineStyle
Definition XLStyles_Common.hpp:66
constexpr const XLStyleIndex XLDefaultCellFormat
Definition XLStyles_Common.hpp:54
constexpr const uint32_t XLDefaultFontCharset
Definition XLStyles_Common.hpp:64
constexpr const bool XLCreateIfMissing
Definition XLStyles_Common.hpp:46
constexpr const XLFillType XLDefaultFillType
Definition XLStyles_Common.hpp:141
constexpr const char * XLDefaultPatternFgColor
Definition XLStyles_Common.hpp:143
constexpr const char * XLDefaultStyleEntriesPrefix
Definition XLStyles_Common.hpp:52
constexpr const char * XLDefaultFontColor
Definition XLStyles_Common.hpp:60
constexpr const char * XLDefaultFontName
Definition XLStyles_Common.hpp:62
constexpr const bool XLDoNotCreate
Definition XLStyles_Common.hpp:47
constexpr const char * XLDefaultStylesPrefix
Definition XLStyles_Common.hpp:51
constexpr const uint32_t XLInvalidUInt32
Definition XLStyles_Common.hpp:39
XLFontSchemeStyle
Definition XLStyles_Common.hpp:97
@ XLFontSchemeInvalid
Definition XLStyles_Common.hpp:101
@ XLFontSchemeNone
Definition XLStyles_Common.hpp:98
@ XLFontSchemeMinor
Definition XLStyles_Common.hpp:100
@ XLFontSchemeMajor
Definition XLStyles_Common.hpp:99
XLReadingOrder
Definition XLStyles_Common.hpp:189
@ XLReadingOrderLeftToRight
Definition XLStyles_Common.hpp:189
@ XLReadingOrderContextual
Definition XLStyles_Common.hpp:189
@ XLReadingOrderRightToLeft
Definition XLStyles_Common.hpp:189
constexpr const bool XLForceFillType
Definition XLStyles_Common.hpp:49
size_t XLStyleIndex
Definition XLStyles_Common.hpp:36
XLVerticalAlignRunStyle
Definition XLStyles_Common.hpp:104
@ XLSubscript
Definition XLStyles_Common.hpp:106
@ XLBaseline
Definition XLStyles_Common.hpp:105
@ XLVerticalAlignRunInvalid
Definition XLStyles_Common.hpp:108
@ XLSuperscript
Definition XLStyles_Common.hpp:107
XLLineStyle
Definition XLStyles_Common.hpp:157
@ XLLineStyleNone
Definition XLStyles_Common.hpp:158
@ XLLineStyleMediumDashDotDot
Definition XLStyles_Common.hpp:170
@ XLLineStyleDashDot
Definition XLStyles_Common.hpp:167
@ XLLineStyleMediumDashed
Definition XLStyles_Common.hpp:166
@ XLLineStyleDotted
Definition XLStyles_Common.hpp:162
@ XLLineStyleSlantDashDot
Definition XLStyles_Common.hpp:171
@ XLLineStyleDouble
Definition XLStyles_Common.hpp:164
@ XLLineStyleInvalid
Definition XLStyles_Common.hpp:172
@ XLLineStyleThick
Definition XLStyles_Common.hpp:163
@ XLLineStyleThin
Definition XLStyles_Common.hpp:159
@ XLLineStyleMediumDashDot
Definition XLStyles_Common.hpp:168
@ XLLineStyleDashed
Definition XLStyles_Common.hpp:161
@ XLLineStyleDashDotDot
Definition XLStyles_Common.hpp:169
@ XLLineStyleMedium
Definition XLStyles_Common.hpp:160
@ XLLineStyleHair
Definition XLStyles_Common.hpp:165
constexpr const uint32_t XLInvalidUInt16
Definition XLStyles_Common.hpp:38
constexpr const uint32_t XLDeleteProperty
Definition XLStyles_Common.hpp:40
constexpr const XLStyleIndex XLInvalidStyleIndex
Definition XLStyles_Common.hpp:57
constexpr const XLPatternType XLDefaultPatternType
Definition XLStyles_Common.hpp:142
constexpr const uint32_t XLDefaultFontFamily
Definition XLStyles_Common.hpp:63
constexpr const char * XLDefaultFontColorTheme
Definition XLStyles_Common.hpp:61
constexpr const bool XLPermitXfID
Definition XLStyles_Common.hpp:44
A high-level, human-ergonomic structure representing the styling of a cell or range....
Definition XLStyle.hpp:29