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

The XLDrawing class is the base class for worksheet drawings (images, charts, etc.). More...

#include <XLDrawing.hpp>

Inheritance diagram for OpenXLSX::XLDrawing:
OpenXLSX::XLXmlFile

Public Member Functions

 XLDrawing ()
 Constructor.
 XLDrawing (gsl::not_null< XLXmlData * > xmlData)
 The constructor.
 XLDrawing (const XLDrawing &other)
 The copy constructor.
 XLDrawing (XLDrawing &&other) noexcept
 Move constructor.
 ~XLDrawing ()=default
 The destructor.
XLDrawing & operator= (const XLDrawing &other)
 Assignment operator.
XLDrawing & operator= (XLDrawing &&other) noexcept
 Move assignment operator.
void addImage (std::string_view rId, std::string_view name, std::string_view description, uint32_t row, uint32_t col, uint32_t width, uint32_t height, const XLImageOptions &options=XLImageOptions())
 Add an image to the drawing.
void addShape (uint32_t row, uint32_t col, const XLVectorShapeOptions &options=XLVectorShapeOptions())
 Add a chart to the drawing.
void addChartAnchor (std::string_view rId, std::string_view name, uint32_t row, uint32_t col, uint32_t width, uint32_t height)
void addChartAnchor (std::string_view rId, std::string_view name, uint32_t row, uint32_t col, XLDistance width, XLDistance height)
void addScaledImage (std::string_view rId, std::string_view name, std::string_view description, std::string_view data, uint32_t row, uint32_t col, double scalingFactor=1.0)
 Add an image to the drawing, automatically maintaining aspect ratio.
XLRelationships & relationships ()
 Get the drawing relationships.
uint32_t imageCount () const
 Get the number of images in the drawing.
XLDrawingItem image (uint32_t index) const
 Get an image item by index.
Public Member Functions inherited from OpenXLSX::XLXmlFile
 XLXmlFile ()=default
 Default constructor.
std::string xmlData (XLXmlSavingDeclaration savingDeclaration=XLXmlSavingDeclaration{}) const
 Method for getting the XML data represented by the object.
 XLXmlFile (XLXmlData *xmlData)
 Constructor. Creates an object based on the xmlData input.
 XLXmlFile (const XLXmlFile &other)=default
 Copy constructor. Default implementation used.
 XLXmlFile (XLXmlFile &&other) noexcept=default
 Move constructor. Default implementation used.
 ~XLXmlFile ()=default
 Destructor. Default implementation used.
bool valid () const
 check whether class is linked to a valid XML file
XLXmlFile & operator= (const XLXmlFile &other)=default
 The copy assignment operator. The default implementation has been used.
XLXmlFile & operator= (XLXmlFile &&other) noexcept=default
 The move assignment operator. The default implementation has been used.
XLDocument & parentDoc ()
 This function provides access to the parent XLDocument object.
const XLDocument & parentDoc () const
 This function provides access to the parent XLDocument object.
XLPackageServices & package ()
 Narrow package-services port (archive, managed XML parts, relationships, content types).
const XLPackageServices & package () const
XLPackagePartFactory & partFactory ()
 Narrow package-part factory port (chart / drawing / image / slicer / sheet accessories).
const XLPackagePartFactory & partFactory () const
const XLSharedStringTable & sharedStringTable () const
 Read-only shared string table (SST) port.
const XLSharedStrings & sharedStrings () const
 Full workbook SST (including getOrCreate / append).
XMLDocument & xmlDocument ()
 This function provides access to the underlying XMLDocument object.
const XMLDocument & xmlDocument () const
 This function provides access to the underlying XMLDocument object.
std::string getXmlPath () const
 Retrieve the path of the XML data in the .xlsx zip archive via m_xmlData->getXmlPath.
const XLXmlData * xmlDataPart () const noexcept
 Access the underlying XLXmlData pointer.
XLXmlData * xmlDataPart () noexcept

Friends

class XLWorksheet
class XLDocument

Additional Inherited Members

Protected Member Functions inherited from OpenXLSX::XLXmlFile
void setXmlData (std::string_view xmlData)
 Provide the XML data represented by the object.
std::string relationshipID () const
 This function returns the relationship ID (the ID used in the XLRelationships objects) for the object.
Protected Attributes inherited from OpenXLSX::XLXmlFile
XLXmlData * m_xmlData {nullptr}

Detailed Description

The XLDrawing class is the base class for worksheet drawings (images, charts, etc.).

Constructor & Destructor Documentation

◆ XLDrawing() [1/4]

OpenXLSX::XLDrawing::XLDrawing ( )
inline

Constructor.

◆ XLDrawing() [2/4]

XLDrawing::XLDrawing ( gsl::not_null< XLXmlData * > xmlData)
explicit

The constructor.

Parameters
xmlDatathe source XML of the drawings file

◆ XLDrawing() [3/4]

XLDrawing::XLDrawing ( const XLDrawing & other)

The copy constructor.

Parameters
otherThe object to be copied.

◆ XLDrawing() [4/4]

XLDrawing::XLDrawing ( XLDrawing && other)
defaultnoexcept

Move constructor.

◆ ~XLDrawing()

OpenXLSX::XLDrawing::~XLDrawing ( )
default

The destructor.

Member Function Documentation

◆ addChartAnchor() [1/2]

void XLDrawing::addChartAnchor ( std::string_view rId,
std::string_view name,
uint32_t row,
uint32_t col,
uint32_t width,
uint32_t height )

◆ addChartAnchor() [2/2]

void XLDrawing::addChartAnchor ( std::string_view rId,
std::string_view name,
uint32_t row,
uint32_t col,
XLDistance width,
XLDistance height )

◆ addImage()

void XLDrawing::addImage ( std::string_view rId,
std::string_view name,
std::string_view description,
uint32_t row,
uint32_t col,
uint32_t width,
uint32_t height,
const XLImageOptions & options = XLImageOptions() )

Add an image to the drawing.

Parameters
rIdthe relationship ID of the image file
namethe name of the image
descriptionthe description of the image
rowthe row where the image should be placed (0-indexed)
colthe column where the image should be placed (0-indexed)
widththe width of the image in pixels
heightthe height of the image in pixels
optionsthe formatting and positioning options

◆ addScaledImage()

void XLDrawing::addScaledImage ( std::string_view rId,
std::string_view name,
std::string_view description,
std::string_view data,
uint32_t row,
uint32_t col,
double scalingFactor = 1.0 )

Add an image to the drawing, automatically maintaining aspect ratio.

Parameters
rIdthe relationship ID of the image file
namethe name of the image
descriptionthe description of the image
datathe binary data of the image (used to detect dimensions)
rowthe row where the image should be placed (0-indexed)
colthe column where the image should be placed (0-indexed)
scalingFactorthe factor to scale the image by (1.0 = original size)

◆ addShape()

void XLDrawing::addShape ( uint32_t row,
uint32_t col,
const XLVectorShapeOptions & options = XLVectorShapeOptions() )

Add a chart to the drawing.

Parameters
rIdthe relationship ID of the chart file
namethe name of the chart
rowthe row where the chart should be placed (0-indexed)
colthe column where the chart should be placed (0-indexed)
widththe width of the chart in pixels
heightthe height of the chart in pixels

◆ image()

XLDrawingItem XLDrawing::image ( uint32_t index) const

Get an image item by index.

Parameters
indexthe index of the image
Returns
an XLDrawingItem object

◆ imageCount()

uint32_t XLDrawing::imageCount ( ) const

Get the number of images in the drawing.

Returns
the number of images

◆ operator=() [1/2]

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

Assignment operator.

◆ operator=() [2/2]

XLDrawing & XLDrawing::operator= ( XLDrawing && other)
defaultnoexcept

Move assignment operator.

◆ relationships()

XLRelationships & XLDrawing::relationships ( )

Get the drawing relationships.

Returns
a reference to the XLRelationships object

fetches XLRelationships for the drawing - creates & assigns the class if empty

◆ XLDocument

friend class XLDocument
friend

◆ XLWorksheet

friend class XLWorksheet
friend

The documentation for this class was generated from the following files:
  • /home/runner/work/OpenXLSX-NX/OpenXLSX-NX/OpenXLSX/headers/XLDrawing.hpp
  • /home/runner/work/OpenXLSX-NX/OpenXLSX-NX/OpenXLSX/sources/XLDrawing.cpp