OpenXLSX 1.12.1
Modern C++ Excel Library (Fork of OpenXLSX by Kenneth Troldal Balslev)
Loading...
Searching...
No Matches
OpenXLSX::XLCellFormats Class Reference

An encapsulation of the XLSX cell style formats. More...

#include <XLStyles_CellFormats.hpp>

Public Member Functions

 XLCellFormats ()
 XLCellFormats (const XMLNode &node, bool permitXfId=false)
 Constructor. New items should only be created through an XLStyles object.
 XLCellFormats (const XLCellFormats &other)
 Copy Constructor.
 XLCellFormats (XLCellFormats &&other)
 Move Constructor.
 ~XLCellFormats ()
XLCellFormats & operator= (const XLCellFormats &other)
 Copy assignment operator.
XLCellFormats & operator= (XLCellFormats &&other) noexcept=default
 Move assignment operator.
size_t count () const
 Get the count of cell style format descriptions.
XLCellFormat cellFormatByIndex (XLStyleIndex index) const
 Get the cell style format description identified by index.
XLCellFormat operator[] (XLStyleIndex index) const
 Operator overload: allow [] as shortcut access to cellFormatByIndex.
XLStyleIndex create (XLCellFormat copyFrom=XLCellFormat{}, std::string_view styleEntriesPrefix=XLDefaultStyleEntriesPrefix)
 Append a new XLCellFormat, based on copyFrom, and return its index in cellXfs (for XLStyles::cellFormats) or cellStyleXfs (for XLStyles::cellStyleFormats).
XLStyleIndex findOrCreate (XLCellFormat copyFrom, std::string_view styleEntriesPrefix=XLDefaultStyleEntriesPrefix)
 Find an existing cell format matching copyFrom's properties, or create a new one.
void rebuild (const std::vector< XMLNode > &nodes)
 Rebuild cell formats from an ordered list of XMLNodes. Updates the underlying XML node and refreshes internal vectors and fingerprint caches.

Detailed Description

An encapsulation of the XLSX cell style formats.

Constructor & Destructor Documentation

◆ XLCellFormats() [1/4]

XLCellFormats::XLCellFormats ( )

◆ XLCellFormats() [2/4]

XLCellFormats::XLCellFormats ( const XMLNode & node,
bool permitXfId = false )
explicit

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

Parameters
nodeAn XMLNode object with the cell formats (cellXfs or cellStyleXfs) item. If no input is provided, a null node is used.
permitXfIdPass-through to XLCellFormat constructor: true (XLPermitXfID) -> setter setXfId is enabled, otherwise throws

◆ XLCellFormats() [3/4]

XLCellFormats::XLCellFormats ( const XLCellFormats & other)

Copy Constructor.

Parameters
otherObject to be copied.

◆ XLCellFormats() [4/4]

XLCellFormats::XLCellFormats ( XLCellFormats && other)

Move Constructor.

Parameters
otherObject to be moved.

◆ ~XLCellFormats()

XLCellFormats::~XLCellFormats ( )

Member Function Documentation

◆ cellFormatByIndex()

XLCellFormat XLCellFormats::cellFormatByIndex ( XLStyleIndex index) const

Get the cell style format description identified by index.

Parameters
indexThe index within the XML sequence
Returns
An XLCellFormat object

◆ count()

size_t XLCellFormats::count ( ) const

Get the count of cell style format descriptions.

Returns
The amount of cell style format description entries

◆ create()

XLStyleIndex XLCellFormats::create ( XLCellFormat copyFrom = XLCellFormat{},
std::string_view styleEntriesPrefix = XLDefaultStyleEntriesPrefix )

Append a new XLCellFormat, based on copyFrom, and return its index in cellXfs (for XLStyles::cellFormats) or cellStyleXfs (for XLStyles::cellStyleFormats).

Parameters
copyFromCan provide an XLCellFormat 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[]

◆ findOrCreate()

XLStyleIndex XLCellFormats::findOrCreate ( XLCellFormat copyFrom,
std::string_view styleEntriesPrefix = XLDefaultStyleEntriesPrefix )

Find an existing cell format matching copyFrom's properties, or create a new one.

Uses a canonical XML fingerprint for O(1) cache lookups after the first call. This is the key deduplication point for bulk formatting operations.

◆ operator=() [1/2]

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

Copy assignment operator.

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

◆ operator=() [2/2]

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

Move assignment operator.

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

◆ operator[]()

XLCellFormat OpenXLSX::XLCellFormats::operator[] ( XLStyleIndex index) const
inline

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

Parameters
indexThe index within the XML sequence
Returns
An XLCellFormat object

◆ rebuild()

void XLCellFormats::rebuild ( const std::vector< XMLNode > & nodes)

Rebuild cell formats from an ordered list of XMLNodes. Updates the underlying XML node and refreshes internal vectors and fingerprint caches.


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