OpenXLSX 1.12.1
Modern C++ Excel Library (Fork of OpenXLSX by Kenneth Troldal Balslev)
Loading...
Searching...
No Matches
XLProperties.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_XLPROPERTIES_HPP
12#define OPENXLSX_XLPROPERTIES_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 <string>
22#include <string_view>
23#include <vector>
24
25// ===== OpenXLSX Includes ===== //
26#include "OpenXLSX-Exports.hpp"
27#include "XLDateTime.hpp"
28#include "XLXmlFile.hpp"
29
30namespace OpenXLSX
31{
35 class OPENXLSX_EXPORT XLProperties : public XLXmlFile
36 {
37 private:
41 void createFromTemplate();
42
43 public:
47 XLProperties() = default;
48
54
58 XLProperties(const XLProperties& other) = default;
59
63 XLProperties(XLProperties&& other) noexcept = default;
64
69
73 XLProperties& operator=(const XLProperties& other) = default;
74
78 XLProperties& operator=(XLProperties&& other) noexcept = default;
79
85 void setProperty(std::string_view name, std::string_view value);
86
92 void setProperty(std::string_view name, int value);
93
99 void setProperty(std::string_view name, double value);
100
106 std::string property(std::string_view name) const;
107
112 void deleteProperty(std::string_view name);
113
114 // Standard Core Properties
115 std::string title() const;
116 void setTitle(std::string_view title);
117
118 std::string subject() const;
119 void setSubject(std::string_view subject);
120
121 std::string creator() const;
122 void setCreator(std::string_view creator);
123
124 std::string keywords() const;
125 void setKeywords(std::string_view keywords);
126
127 std::string description() const;
128 void setDescription(std::string_view description);
129
130 std::string lastModifiedBy() const;
131 void setLastModifiedBy(std::string_view author);
132
133 std::string revision() const;
134 void setRevision(std::string_view revision);
135
136 std::string lastPrinted() const;
137 void setLastPrinted(std::string_view date);
138
139 XLDateTime created() const;
140 void setCreated(const XLDateTime& date);
141
142 XLDateTime modified() const;
143 void setModified(const XLDateTime& date);
144
145 std::string category() const;
146 void setCategory(std::string_view category);
147
148 std::string contentStatus() const;
149 void setContentStatus(std::string_view status);
150 };
151
155 class OPENXLSX_EXPORT XLAppProperties : public XLXmlFile
156 {
157 private:
162 void createFromTemplate(XMLDocument const& workbookXml);
163
164 public:
168 XLAppProperties() = default;
169
175 explicit XLAppProperties(XLXmlData* xmlData, XMLDocument const& workbookXml);
176
182
186 XLAppProperties(const XLAppProperties& other) = default;
187
191 XLAppProperties(XLAppProperties&& other) noexcept = default;
192
197
201 XLAppProperties& operator=(const XLAppProperties& other) = default;
202
206 XLAppProperties& operator=(XLAppProperties&& other) noexcept = default;
207
212 void incrementSheetCount(int16_t increment);
213
218 void alignWorksheets(const std::vector<std::string>& workbookSheetNames);
219
224 void addSheetName(std::string_view title);
225
230 void deleteSheetName(std::string_view title);
231
237 void setSheetName(std::string_view oldTitle, std::string_view newTitle);
238
244 void addHeadingPair(std::string_view name, int value);
245
250 void deleteHeadingPair(std::string_view name);
251
257 void setHeadingPair(std::string_view name, int newValue);
258
264 void setProperty(std::string_view name, std::string_view value);
265
271 std::string property(std::string_view name) const;
272
277 void deleteProperty(std::string_view name);
278
283 void appendSheetName(std::string_view sheetName);
284
289 void prependSheetName(std::string_view sheetName);
290
296 void insertSheetName(std::string_view sheetName, unsigned int index);
297 };
298
302 class OPENXLSX_EXPORT XLCustomProperties : public XLXmlFile
303 {
304 private:
308 void createFromTemplate();
309
310 public:
315
321
325 XLCustomProperties(const XLCustomProperties& other) = default;
326
330 XLCustomProperties(XLCustomProperties&& other) noexcept = default;
331
336
341
345 XLCustomProperties& operator=(XLCustomProperties&& other) noexcept = default;
346
352 void setProperty(std::string_view name, std::string_view value);
353
359 void setProperty(std::string_view name, const char* value);
360
366 void setProperty(std::string_view name, int value);
367
373 void setProperty(std::string_view name, double value);
374
380 void setProperty(std::string_view name, bool value);
381
387 void setProperty(std::string_view name, const XLDateTime& value);
388
394 std::string property(std::string_view name) const;
395
400 void deleteProperty(std::string_view name);
401 };
402
403} // namespace OpenXLSX
404
405#ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
406# pragma warning(pop)
407#endif // _MSC_VER
408
409#endif // OPENXLSX_XLPROPERTIES_HPP
XLAppProperties & operator=(XLAppProperties &&other) noexcept=default
Move assignment operator.
void prependSheetName(std::string_view sheetName)
Prepend a sheet name.
Definition XLProperties.cpp:584
~XLAppProperties()
Destructor.
XLAppProperties(const XLAppProperties &other)=default
Copy constructor.
void setProperty(std::string_view name, std::string_view value)
Set a generic property in app.xml.
Definition XLProperties.cpp:539
XLAppProperties & operator=(const XLAppProperties &other)=default
Copy assignment operator.
void setSheetName(std::string_view oldTitle, std::string_view newTitle)
Update a sheet name in TitlesOfParts.
Definition XLProperties.cpp:448
void addSheetName(std::string_view title)
Add a sheet name to TitlesOfParts.
Definition XLProperties.cpp:420
void deleteSheetName(std::string_view title)
Delete a sheet name from TitlesOfParts.
Definition XLProperties.cpp:431
void addHeadingPair(std::string_view name, int value)
Add a HeadingPair (e.g., "Worksheets").
Definition XLProperties.cpp:464
void insertSheetName(std::string_view sheetName, unsigned int index)
Insert a sheet name at a specific index.
Definition XLProperties.cpp:595
std::string property(std::string_view name) const
Get a property value from app.xml.
Definition XLProperties.cpp:551
void alignWorksheets(const std::vector< std::string > &workbookSheetNames)
Align the sheet names in TitlesOfParts with the actual workbook sheet names.
Definition XLProperties.cpp:393
void deleteProperty(std::string_view name)
Delete a property from app.xml.
Definition XLProperties.cpp:562
XLAppProperties()=default
Default constructor.
XLAppProperties(XLAppProperties &&other) noexcept=default
Move constructor.
void deleteHeadingPair(std::string_view name)
Delete a HeadingPair.
Definition XLProperties.cpp:500
void appendSheetName(std::string_view sheetName)
Append a sheet name.
Definition XLProperties.cpp:573
void incrementSheetCount(int16_t increment)
Increment or decrement the worksheet count in HeadingPairs and TitlesOfParts.
Definition XLProperties.cpp:378
void setHeadingPair(std::string_view name, int newValue)
Update a HeadingPair value.
Definition XLProperties.cpp:525
XLCustomProperties(XLCustomProperties &&other) noexcept=default
Move constructor.
XLCustomProperties & operator=(const XLCustomProperties &other)=default
Copy assignment operator.
XLCustomProperties()=default
Default constructor.
std::string property(std::string_view name) const
Get a custom property value as a string.
Definition XLProperties.cpp:752
void setProperty(std::string_view name, std::string_view value)
Set a string custom property (vt:lpwstr).
Definition XLProperties.cpp:697
XLCustomProperties & operator=(XLCustomProperties &&other) noexcept=default
Move assignment operator.
XLCustomProperties(const XLCustomProperties &other)=default
Copy constructor.
void deleteProperty(std::string_view name)
Delete a custom property.
Definition XLProperties.cpp:767
Manages date and time values according to the Excel 1900 date system.
Definition XLDateTime.hpp:40
std::string creator() const
Definition XLProperties.cpp:247
std::string contentStatus() const
Definition XLProperties.cpp:296
XLDateTime created() const
Definition XLProperties.cpp:265
void setTitle(std::string_view title)
Definition XLProperties.cpp:242
XLDateTime modified() const
Definition XLProperties.cpp:279
XLProperties(XLProperties &&other) noexcept=default
Move constructor.
XLProperties & operator=(const XLProperties &other)=default
Copy assignment operator.
void setCreated(const XLDateTime &date)
Definition XLProperties.cpp:271
XLProperties & operator=(XLProperties &&other) noexcept=default
Move assignment operator.
std::string revision() const
Definition XLProperties.cpp:259
void setProperty(std::string_view name, std::string_view value)
Set a property by name.
Definition XLProperties.cpp:199
XLProperties(const XLProperties &other)=default
Copy constructor.
std::string lastPrinted() const
Definition XLProperties.cpp:262
std::string lastModifiedBy() const
Definition XLProperties.cpp:256
std::string keywords() const
Definition XLProperties.cpp:250
void setCreator(std::string_view creator)
Definition XLProperties.cpp:248
XLProperties()=default
Default constructor.
std::string property(std::string_view name) const
Get a property value as a string.
Definition XLProperties.cpp:221
void setKeywords(std::string_view keywords)
Definition XLProperties.cpp:251
void setModified(const XLDateTime &date)
Definition XLProperties.cpp:285
void setLastModifiedBy(std::string_view author)
Definition XLProperties.cpp:257
std::string title() const
Definition XLProperties.cpp:241
std::string subject() const
Definition XLProperties.cpp:244
void setLastPrinted(std::string_view date)
Definition XLProperties.cpp:263
void setDescription(std::string_view description)
Definition XLProperties.cpp:254
std::string description() const
Definition XLProperties.cpp:253
~XLProperties()
Destructor.
void deleteProperty(std::string_view name)
Delete a property.
Definition XLProperties.cpp:233
void setSubject(std::string_view subject)
Definition XLProperties.cpp:245
void setContentStatus(std::string_view status)
Definition XLProperties.cpp:297
void setCategory(std::string_view category)
Definition XLProperties.cpp:294
void setRevision(std::string_view revision)
Definition XLProperties.cpp:260
std::string category() const
Definition XLProperties.cpp:293
The XLXmlData class encapsulates the properties and behaviour of the .xml files in an ....
Definition XLXmlData.hpp:79
std::string xmlData(XLXmlSavingDeclaration savingDeclaration=XLXmlSavingDeclaration{}) const
Method for getting the XML data represented by the object.
Definition XLXmlFile.cpp:49
XLXmlFile()=default
Default constructor.
Definition IXLCellProvider.hpp:24
OpenXLSX_xml_document XMLDocument
Definition XLXmlParser.hpp:65