OpenXLSX 1.9.1
Loading...
Searching...
No Matches
OpenXLSX::XLNumberFormats Class Reference

An encapsulation of the XLSX number formats (numFmts) More...

#include <XLStyles.hpp>

Public Member Functions

 XLNumberFormats ()
 
 XLNumberFormats (const XMLNode &node)
 Constructor. New items should only be created through an XLStyles object.
 
 XLNumberFormats (const XLNumberFormats &other)
 Copy Constructor.
 
 XLNumberFormats (XLNumberFormats &&other)
 Move Constructor.
 
 ~XLNumberFormats ()
 
XLNumberFormatsoperator= (const XLNumberFormats &other)
 Copy assignment operator.
 
XLNumberFormatsoperator= (XLNumberFormats &&other) noexcept=default
 Move assignment operator.
 
size_t count () const
 Get the count of number formats.
 
XLNumberFormat numberFormatByIndex (XLStyleIndex index) const
 Get the number format identified by index.
 
XLNumberFormat operator[] (XLStyleIndex index) const
 Operator overload: allow [] as shortcut access to numberFormatByIndex.
 
XLNumberFormat numberFormatById (uint32_t numberFormatId) const
 Get the number format identified by numberFormatId.
 
uint32_t numberFormatIdFromIndex (XLStyleIndex index) const
 Get the numFmtId from the number format identified by index.
 
uint32_t createNumberFormat (std::string_view formatCode)
 Create a new custom number format with a unique ID.
 
uint32_t getFreeNumberFormatId () const
 Get a free (unused) number format ID, skipping reserved IDs (0-163).
 
XLStyleIndex create (XLNumberFormat copyFrom=XLNumberFormat{}, std::string_view styleEntriesPrefix=XLDefaultStyleEntriesPrefix)
 Append a new XLNumberFormat, based on copyFrom, and return its index in numFmts node.
 

Detailed Description

An encapsulation of the XLSX number formats (numFmts)

Constructor & Destructor Documentation

◆ XLNumberFormats() [1/4]

XLNumberFormats::XLNumberFormats ( )

◆ XLNumberFormats() [2/4]

XLNumberFormats::XLNumberFormats ( const XMLNode node)
explicit

Constructor. New items should only be created through an XLStyles object.

Parameters
nodeAn XMLNode object with the styles item. If no input is provided, a null node is used.

◆ XLNumberFormats() [3/4]

XLNumberFormats::XLNumberFormats ( const XLNumberFormats other)

Copy Constructor.

Parameters
otherObject to be copied.

◆ XLNumberFormats() [4/4]

XLNumberFormats::XLNumberFormats ( XLNumberFormats &&  other)

Move Constructor.

Parameters
otherObject to be moved.

◆ ~XLNumberFormats()

XLNumberFormats::~XLNumberFormats ( )

Member Function Documentation

◆ count()

size_t XLNumberFormats::count ( ) const

Get the count of number formats.

Returns
The amount of entries in the number formats

◆ create()

XLStyleIndex XLNumberFormats::create ( XLNumberFormat  copyFrom = XLNumberFormat{},
std::string_view  styleEntriesPrefix = XLDefaultStyleEntriesPrefix 
)

Append a new XLNumberFormat, based on copyFrom, and return its index in numFmts node.

Parameters
copyFromCan provide an XLNumberFormat to use as template for the new style
styleEntriesPrefixPrefix the newly created cell style XMLNode with this pugi::node_pcdata text
Returns
The index of the new style as used by operator[]

◆ createNumberFormat()

uint32_t XLNumberFormats::createNumberFormat ( std::string_view  formatCode)

Create a new custom number format with a unique ID.

Parameters
formatCodeThe explicit format code string
Returns
The unique number format ID (numFmtId)

◆ getFreeNumberFormatId()

uint32_t XLNumberFormats::getFreeNumberFormatId ( ) const

Get a free (unused) number format ID, skipping reserved IDs (0-163).

Returns
A free ID starting from 164.

◆ numberFormatById()

XLNumberFormat XLNumberFormats::numberFormatById ( uint32_t  numberFormatId) const

Get the number format identified by numberFormatId.

Parameters
numberFormatIda numFmtId reference to a number format
Returns
An XLNumberFormat object
Exceptions
XLExceptionif no match for numberFormatId is found within m_numberFormats

◆ numberFormatByIndex()

XLNumberFormat XLNumberFormats::numberFormatByIndex ( XLStyleIndex  index) const

Get the number format identified by index.

Parameters
indexan array index within XLStyles::numberFormats()
Returns
An XLNumberFormat object
Exceptions
XLExceptionwhen index is out of m_numberFormats range

◆ numberFormatIdFromIndex()

uint32_t XLNumberFormats::numberFormatIdFromIndex ( XLStyleIndex  index) const

Get the numFmtId from the number format identified by index.

Parameters
indexan array index within XLStyles::numberFormats()
Returns
the uint32_t numFmtId corresponding to index
Exceptions
XLExceptionwhen index is out of m_numberFormats range

◆ operator=() [1/2]

XLNumberFormats & XLNumberFormats::operator= ( const XLNumberFormats other)

Copy assignment operator.

Parameters
otherRight hand side of assignment operation.
Returns
A reference to the lhs object.

◆ operator=() [2/2]

XLNumberFormats & OpenXLSX::XLNumberFormats::operator= ( XLNumberFormats &&  other)
defaultnoexcept

Move assignment operator.

Parameters
otherRight hand side of assignment operation.
Returns
A reference to lhs object.

◆ operator[]()

XLNumberFormat OpenXLSX::XLNumberFormats::operator[] ( XLStyleIndex  index) const
inline

Operator overload: allow [] as shortcut access to numberFormatByIndex.


The documentation for this class was generated from the following files: