11#ifndef OPENXLSX_XLPIVOTTABLE_HPP
12#define OPENXLSX_XLPIVOTTABLE_HPP
14#include "OpenXLSX-Exports.hpp"
23 enum class XLPivotSubtotal {
Sum,
Average,
Count,
Max,
Min,
Product,
CountNums,
StdDev,
StdDevP,
Var,
VarP };
91 f.
name = std::move(fieldName);
93 m_rows.push_back(std::move(f));
99 m_rows.push_back(std::move(field));
106 f.
name = std::move(fieldName);
108 m_columns.push_back(std::move(f));
114 m_columns.push_back(std::move(field));
119 std::string customName =
"",
121 uint32_t numFmtId = 0,
125 f.
name = std::move(fieldName);
130 m_data.push_back(std::move(f));
136 m_data.push_back(std::move(field));
143 f.
name = std::move(fieldName);
145 m_filters.push_back(std::move(f));
151 m_filters.push_back(std::move(field));
157 m_pivotTableStyleName = std::move(styleName);
162 m_dataOnRows = value;
167 m_rowGrandTotals = value;
172 m_colGrandTotals = value;
182 m_useAutoFormatting = value;
187 m_pageOverThenDown = value;
197 m_compactData = value;
207 m_showRowHeaders = value;
212 m_showColHeaders = value;
217 m_showRowStripes = value;
222 m_showColStripes = value;
227 m_showLastColumn = value;
233 m_classicLayout = value;
238 m_fieldPrintTitles = value;
243 m_itemPrintTitles = value;
253 m_locationRange = std::move(range);
258 [[nodiscard]]
const std::string&
name()
const {
return m_name; }
259 [[nodiscard]]
const std::string&
sourceRange()
const {
return m_sourceRange; }
260 [[nodiscard]]
const std::string&
targetCell()
const {
return m_targetCell; }
261 [[nodiscard]]
const std::string&
locationRange()
const {
return m_locationRange; }
262 [[nodiscard]]
const std::vector<XLPivotField>&
rows()
const {
return m_rows; }
263 [[nodiscard]]
const std::vector<XLPivotField>&
columns()
const {
return m_columns; }
264 [[nodiscard]]
const std::vector<XLPivotField>&
data()
const {
return m_data; }
265 [[nodiscard]]
const std::vector<XLPivotField>&
filters()
const {
return m_filters; }
268 [[nodiscard]]
bool dataOnRows()
const {
return m_dataOnRows; }
271 [[nodiscard]]
bool showDrill()
const {
return m_showDrill; }
274 [[nodiscard]]
bool mergeItem()
const {
return m_mergeItem; }
276 [[nodiscard]]
bool showError()
const {
return m_showError; }
336 std::string m_sourceRange;
337 std::string m_targetCell;
338 std::string m_locationRange;
340 std::vector<XLPivotField> m_rows;
341 std::vector<XLPivotField> m_columns;
342 std::vector<XLPivotField> m_data;
343 std::vector<XLPivotField> m_filters;
345 bool m_dataOnRows{
false};
346 bool m_rowGrandTotals{
true};
347 bool m_colGrandTotals{
true};
348 bool m_showDrill{
true};
349 bool m_useAutoFormatting{
false};
350 bool m_pageOverThenDown{
false};
351 bool m_mergeItem{
false};
352 bool m_compactData{
true};
353 bool m_showError{
false};
354 bool m_showRowHeaders{
true};
355 bool m_showColHeaders{
true};
356 bool m_showRowStripes{
false};
357 bool m_showColStripes{
false};
358 bool m_showLastColumn{
false};
360 bool m_classicLayout{
false};
361 bool m_fieldPrintTitles{
false};
362 bool m_itemPrintTitles{
false};
364 std::string m_pivotTableStyleName{
"PivotStyleLight16"};
390 std::string
name()
const;
439 [[nodiscard]] std::vector<std::string>
fieldNames()
const;
Definition XLPivotTable.hpp:421
~XLPivotCacheDefinition()=default
void changeSourceRange(std::string_view newRange)
Definition XLPivotTable.cpp:277
XLPivotCacheDefinition(XLPivotCacheDefinition &&other) noexcept=default
std::string sourceRange() const
Definition XLPivotTable.cpp:262
XLPivotCacheDefinition()
Definition XLPivotTable.hpp:425
std::vector< std::string > fieldNames() const
Cache field names in definition order.
Definition XLPivotTable.cpp:307
XLPivotCacheDefinition & operator=(const XLPivotCacheDefinition &other)=default
XLPivotCacheDefinition & operator=(XLPivotCacheDefinition &&other) noexcept=default
class XLRelationships relationships()
Definition XLPivotTable.cpp:544
XLPivotCacheDefinition(const XLPivotCacheDefinition &other)=default
Definition XLPivotTable.hpp:443
XLPivotCacheRecords & operator=(const XLPivotCacheRecords &other)=default
~XLPivotCacheRecords()=default
XLPivotCacheRecords()
Definition XLPivotTable.hpp:445
XLPivotCacheRecords & operator=(XLPivotCacheRecords &&other) noexcept=default
XLPivotCacheRecords(const XLPivotCacheRecords &other)=default
XLPivotCacheRecords(XLPivotCacheRecords &&other) noexcept=default
Definition XLPivotTable.hpp:74
bool dataOnRows() const
Definition XLPivotTable.hpp:268
void setNameInternal(std::string v)
Definition XLPivotTable.hpp:288
XLPivotTableOptions & setFieldPrintTitles(bool value)
Definition XLPivotTable.hpp:236
XLPivotTableOptions & setShowRowStripes(bool value)
Definition XLPivotTable.hpp:215
XLPivotTableOptions & addRowField(XLPivotField field)
Definition XLPivotTable.hpp:97
XLPivotTableOptions & setRowGrandTotals(bool value)
Definition XLPivotTable.hpp:165
bool showColStripes() const
Definition XLPivotTable.hpp:280
const std::string & targetCell() const
Definition XLPivotTable.hpp:260
XLPivotTableOptions & setUseAutoFormatting(bool value)
Definition XLPivotTable.hpp:180
XLPivotTableOptions & setItemPrintTitles(bool value)
Definition XLPivotTable.hpp:241
bool useAutoFormatting() const
Definition XLPivotTable.hpp:272
XLPivotTableOptions & addFilterField(std::string fieldName, std::vector< std::string > selectedItems={})
Definition XLPivotTable.hpp:140
XLPivotTableOptions & addFilterField(XLPivotField field)
Definition XLPivotTable.hpp:149
XLPivotTableOptions & setColGrandTotals(bool value)
Definition XLPivotTable.hpp:170
bool showRowHeaders() const
Definition XLPivotTable.hpp:277
void setTargetCellInternal(std::string v)
Definition XLPivotTable.hpp:290
bool classicLayout() const
Definition XLPivotTable.hpp:283
const std::string & pivotTableStyleName() const
Definition XLPivotTable.hpp:266
bool fieldPrintTitles() const
Definition XLPivotTable.hpp:284
XLPivotTableOptions & setShowLastColumn(bool value)
Definition XLPivotTable.hpp:225
XLPivotTableOptions & addDataField(std::string fieldName, std::string customName="", XLPivotSubtotal subtotal=XLPivotSubtotal::Sum, uint32_t numFmtId=0, XLPivotShowValuesAsOptions showValuesAs={})
Definition XLPivotTable.hpp:118
const std::string & name() const
Definition XLPivotTable.hpp:258
bool showDrill() const
Definition XLPivotTable.hpp:271
XLPivotTableOptions & setCompactData(bool value)
Definition XLPivotTable.hpp:195
const std::vector< XLPivotField > & columns() const
Definition XLPivotTable.hpp:263
bool showLastColumn() const
Definition XLPivotTable.hpp:281
const std::string & sourceRange() const
Definition XLPivotTable.hpp:259
XLPivotTableOptions & setClassicLayout(bool value)
Definition XLPivotTable.hpp:231
XLPivotTableOptions & setPageOverThenDown(bool value)
Definition XLPivotTable.hpp:185
XLPivotTableOptions & setMergeItem(bool value)
Definition XLPivotTable.hpp:190
bool compactData() const
Definition XLPivotTable.hpp:275
void setPivotTableStyleNameInternal(std::string v)
Definition XLPivotTable.hpp:295
const std::string & locationRange() const
Definition XLPivotTable.hpp:261
const std::vector< XLPivotField > & data() const
Definition XLPivotTable.hpp:264
void setSourceRangeInternal(std::string v)
Definition XLPivotTable.hpp:289
XLPivotTableOptions & setShowRowHeaders(bool value)
Definition XLPivotTable.hpp:205
bool pageOverThenDown() const
Definition XLPivotTable.hpp:273
bool showColHeaders() const
Definition XLPivotTable.hpp:278
void setColumnsInternal(std::vector< XLPivotField > v)
Definition XLPivotTable.hpp:292
XLPivotTableOptions & setLocationRange(std::string range)
Optional explicit location rectangle (e.g. "G4:M30"). When empty, the library estimates size from tar...
Definition XLPivotTable.hpp:251
XLPivotTableOptions & setShowColHeaders(bool value)
Definition XLPivotTable.hpp:210
void setRowsInternal(std::vector< XLPivotField > v)
Definition XLPivotTable.hpp:291
XLPivotTableOptions & setShowError(bool value)
Definition XLPivotTable.hpp:200
void setLocationRangeInternal(std::string v)
Definition XLPivotTable.hpp:296
const std::vector< XLPivotField > & filters() const
Definition XLPivotTable.hpp:265
XLPivotTableOptions & setShowColStripes(bool value)
Definition XLPivotTable.hpp:220
void setFiltersInternal(std::vector< XLPivotField > v)
Definition XLPivotTable.hpp:294
XLPivotTableOptions & setShowDrill(bool value)
Definition XLPivotTable.hpp:175
XLPivotTableOptions & addRowField(std::string fieldName, std::vector< std::string > selectedItems={})
Definition XLPivotTable.hpp:88
XLPivotTableOptions & setDataOnRows(bool value)
Definition XLPivotTable.hpp:160
XLPivotTableOptions & setPivotTableStyle(std::string styleName)
Definition XLPivotTable.hpp:155
bool showError() const
Definition XLPivotTable.hpp:276
XLPivotTableOptions & addDataField(XLPivotField field)
Definition XLPivotTable.hpp:134
void setBoolFlags(bool dataOnRows, bool rowGrandTotals, bool colGrandTotals, bool showDrill, bool useAutoFormatting, bool pageOverThenDown, bool mergeItem, bool compactData, bool showError, bool showRowHeaders, bool showColHeaders, bool showRowStripes, bool showColStripes, bool showLastColumn, bool classicLayout, bool fieldPrintTitles, bool itemPrintTitles)
Definition XLPivotTable.hpp:297
XLPivotTableOptions(std::string name, std::string sourceRange, std::string targetCell)
Construct fully initialized Pivot Table options.
Definition XLPivotTable.hpp:82
XLPivotTableOptions & addColumnField(std::string fieldName, std::vector< std::string > selectedItems={})
Definition XLPivotTable.hpp:103
XLPivotTableOptions & addColumnField(XLPivotField field)
Definition XLPivotTable.hpp:112
bool itemPrintTitles() const
Definition XLPivotTable.hpp:285
bool rowGrandTotals() const
Definition XLPivotTable.hpp:269
bool showRowStripes() const
Definition XLPivotTable.hpp:279
bool colGrandTotals() const
Definition XLPivotTable.hpp:270
bool mergeItem() const
Definition XLPivotTable.hpp:274
const std::vector< XLPivotField > & rows() const
Definition XLPivotTable.hpp:262
void setDataInternal(std::vector< XLPivotField > v)
Definition XLPivotTable.hpp:293
Definition XLPivotTable.hpp:368
XLPivotTable()
Definition XLPivotTable.hpp:372
XLPivotTable(const XLPivotTable &other)=default
void setRefreshOnLoad(bool refresh=true)
Tell Excel to refresh this pivot table when the file is opened.
Definition XLPivotTable.cpp:209
XLPivotTable(XLPivotTable &&other) noexcept=default
XLPivotTable & operator=(const XLPivotTable &other)=default
void setName(std::string_view name)
Definition XLPivotTable.cpp:252
class XLRelationships relationships()
Definition XLPivotTable.cpp:542
XLPivotTable & operator=(XLPivotTable &&other) noexcept=default
std::string targetCell() const
Get the target location anchor (first cell of location/.
Definition XLPivotTable.cpp:153
XLPivotTableOptions options() const
Best-effort reconstruction of create-time options from package XML.
Definition XLPivotTable.cpp:384
void changeSourceRange(std::string_view newRange)
Change the data source range for the pivot table.
Definition XLPivotTable.cpp:204
std::string name() const
Get the name of the pivot table.
Definition XLPivotTable.cpp:151
class XLPivotCacheDefinition cacheDefinition() const
Get the pivot cache definition object.
Definition XLPivotTable.cpp:167
std::string sourceRange() const
Get the data source range or table/defined name.
Definition XLPivotTable.cpp:199
Definition XLRelationships.hpp:150
The XLXmlData class encapsulates the properties and behaviour of the .xml files in an ....
Definition XLXmlData.hpp:79
XLXmlFile()=default
Default constructor.
Definition IXLCellProvider.hpp:24
const char * pivotShowValuesAsToString(XLPivotShowValuesAs t)
Definition XLPivotTable.cpp:27
bool pivotShowValuesAsNeedsBaseField(XLPivotShowValuesAs t)
Definition XLPivotTable.cpp:83
XLPivotSubtotal
Definition XLPivotTable.hpp:23
@ CountNums
Definition XLPivotTable.hpp:23
@ VarP
Definition XLPivotTable.hpp:23
@ StdDev
Definition XLPivotTable.hpp:23
@ Var
Definition XLPivotTable.hpp:23
@ Sum
Definition XLPivotTable.hpp:23
@ Average
Definition XLPivotTable.hpp:23
@ Product
Definition XLPivotTable.hpp:23
@ Count
Definition XLPivotTable.hpp:23
@ StdDevP
Definition XLPivotTable.hpp:23
XLPivotShowValuesAs
"Show Values As" calculation for pivot data fields (OOXML showDataAs / x14:dataField).
Definition XLPivotTable.hpp:29
@ PercentOfParentColumnTotal
x14 percentOfParentCol
Definition XLPivotTable.hpp:36
@ PercentOfParentRowTotal
x14 percentOfParentRow
Definition XLPivotTable.hpp:35
@ DifferenceFrom
difference (baseField + baseItem)
Definition XLPivotTable.hpp:38
@ RunningTotalIn
runTotal (baseField)
Definition XLPivotTable.hpp:40
@ PercentOfParentTotal
x14 percentOfParent (needs baseField)
Definition XLPivotTable.hpp:37
@ PercentOf
percent (needs baseField + baseItem)
Definition XLPivotTable.hpp:34
@ PercentDifferenceFrom
percentDiff (baseField + baseItem)
Definition XLPivotTable.hpp:39
@ PercentOfGrandTotal
percentOfTotal
Definition XLPivotTable.hpp:31
@ Index
x14 index
Definition XLPivotTable.hpp:44
@ Normal
Definition XLPivotTable.hpp:30
@ PercentOfColumnTotal
percentOfCol
Definition XLPivotTable.hpp:32
@ RankLargestToSmallest
x14 rankDescending (baseField)
Definition XLPivotTable.hpp:43
@ PercentOfRowTotal
percentOfRow
Definition XLPivotTable.hpp:33
@ RankSmallestToLargest
x14 rankAscending (baseField)
Definition XLPivotTable.hpp:42
@ PercentRunningTotalIn
x14 percentOfRunningTotal (baseField)
Definition XLPivotTable.hpp:41
const char * pivotSubtotalToString(XLPivotSubtotal s)
Definition XLPivotTable.cpp:112
@ Max
Definition XLChart.hpp:118
@ Min
Definition XLChart.hpp:118
XLPivotSubtotal pivotSubtotalFromString(std::string_view s)
Definition XLPivotTable.cpp:129
bool pivotShowValuesAsNeedsX14(XLPivotShowValuesAs t)
Definition XLPivotTable.cpp:67
bool pivotShowValuesAsNeedsBaseItem(XLPivotShowValuesAs t)
Definition XLPivotTable.cpp:100
XLPivotShowValuesAs pivotShowValuesAsFromString(std::string_view s)
Definition XLPivotTable.cpp:48
Definition XLCellIterator.hpp:131
Definition XLPivotTable.hpp:55
XLPivotShowValuesAsOptions showValuesAs
Definition XLPivotTable.hpp:70
std::vector< std::string > selectedItems
Definition XLPivotTable.hpp:60
std::string customName
data field caption; also axis display name when set
Definition XLPivotTable.hpp:58
bool showAll
Definition XLPivotTable.hpp:65
std::string name
Definition XLPivotTable.hpp:56
XLPivotSubtotal subtotal
Definition XLPivotTable.hpp:57
bool defaultSubtotal
Definition XLPivotTable.hpp:67
uint32_t numFmtId
Definition XLPivotTable.hpp:59
bool compact
Definition XLPivotTable.hpp:63
bool insertBlankRow
Definition XLPivotTable.hpp:66
bool outline
Definition XLPivotTable.hpp:64
Definition XLPivotTable.hpp:48
std::string baseField
cache field name when required
Definition XLPivotTable.hpp:50
XLPivotShowValuesAs type
Definition XLPivotTable.hpp:49
std::string baseItem
shared-item label when required
Definition XLPivotTable.hpp:51