OpenXLSX 1.9.1
Loading...
Searching...
No Matches
OpenXLSX::XLSheet Class Referencefinal

The XLAbstractSheet is a generalized sheet class, which functions as superclass for specialized classes, such as XLWorksheet. It implements functionality common to all sheet types. This is a pure abstract class, so it cannot be instantiated. More...

#include <XLSheet.hpp>

Inheritance diagram for OpenXLSX::XLSheet:
OpenXLSX::XLXmlFile

Public Member Functions

 XLSheet (XLXmlData *xmlData)
 The constructor. There are no default constructor, so all parameters must be provided for constructing an XLAbstractSheet object. Since this is a pure abstract class, instantiation is only possible via one of the derived classes.
 
 XLSheet (const XLSheet &other)=default
 The copy constructor.
 
 XLSheet (XLSheet &&other) noexcept=default
 
 ~XLSheet ()=default
 The destructor.
 
XLSheetoperator= (const XLSheet &other)=default
 Assignment operator.
 
XLSheetoperator= (XLSheet &&other) noexcept=default
 
XLSheetState visibility () const
 Method for getting the current visibility state of the sheet.
 
void setVisibility (XLSheetState state)
 Method for setting the state of the sheet.
 
XLColor color () const
 
void setColor (const XLColor &color)
 
uint16_t index () const
 Method for getting the index of the sheet.
 
void setIndex (uint16_t index)
 Method for setting the index of the sheet. This effectively moves the sheet to a different position.
 
std::string name () const
 Method to retrieve the name of the sheet.
 
void setName (const std::string &name)
 Method for renaming the sheet.
 
bool isSelected () const
 Determine whether the sheet is selected.
 
void setSelected (bool selected)
 
bool isActive () const
 
bool setActive ()
 
template<typename SheetType , typename = std::enable_if_t<std::is_same_v<SheetType, XLWorksheet> or std::is_same_v<SheetType, XLChartsheet>>>
bool isType () const
 Method to get the type of the sheet.
 
void clone (const std::string &newName)
 Method for cloning the sheet.
 
template<typename T , typename = std::enable_if_t<std::is_same_v<T, XLWorksheet> or std::is_same_v<T, XLChartsheet>>>
get () const
 
 operator XLWorksheet () const
 
 operator XLChartsheet () const
 
void print (std::basic_ostream< char > &ostr) const
 Print the XML contents of the XLSheet using the underlying XMLNode print function.
 
- 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
 
XLXmlFileoperator= (const XLXmlFile &other)=default
 The copy assignment operator. The default implementation has been used.
 
XLXmlFileoperator= (XLXmlFile &&other) noexcept=default
 The move assignment operator. The default implementation has been used.
 
XLDocumentparentDoc ()
 This function provides access to the parent XLDocument object.
 
const XLDocumentparentDoc () const
 This function provides access to the parent XLDocument object.
 
XMLDocumentxmlDocument ()
 This function provides access to the underlying XMLDocument object.
 
const XMLDocumentxmlDocument () 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.
 

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
XLXmlDatam_xmlData {nullptr}
 

Detailed Description

The XLAbstractSheet is a generalized sheet class, which functions as superclass for specialized classes, such as XLWorksheet. It implements functionality common to all sheet types. This is a pure abstract class, so it cannot be instantiated.

Constructor & Destructor Documentation

◆ XLSheet() [1/3]

XLSheet::XLSheet ( XLXmlData xmlData)
explicit

The constructor. There are no default constructor, so all parameters must be provided for constructing an XLAbstractSheet object. Since this is a pure abstract class, instantiation is only possible via one of the derived classes.

Parameters
xmlData

◆ XLSheet() [2/3]

OpenXLSX::XLSheet::XLSheet ( const XLSheet other)
default

The copy constructor.

Parameters
otherThe object to be copied.
Note
The default copy constructor is used, i.e. only shallow copying of pointer data members.

◆ XLSheet() [3/3]

OpenXLSX::XLSheet::XLSheet ( XLSheet &&  other)
defaultnoexcept
Parameters
other

◆ ~XLSheet()

OpenXLSX::XLSheet::~XLSheet ( )
default

The destructor.

Note
The default destructor is used, since cleanup of pointer data members is not required.

Member Function Documentation

◆ clone()

void XLSheet::clone ( const std::string &  newName)

Method for cloning the sheet.

Parameters
newNameA std::string with the name of the clone
Returns
A pointer to the cloned object.
Note
This is a pure abstract method. I.e. it is implemented in subclasses.

◆ color()

XLColor XLSheet::color ( ) const
Returns

◆ get()

template<typename T , typename = std::enable_if_t<std::is_same_v<T, XLWorksheet> or std::is_same_v<T, XLChartsheet>>>
T OpenXLSX::XLSheet::get ( ) const
inline
Template Parameters
T
Returns

◆ index()

uint16_t XLSheet::index ( ) const

Method for getting the index of the sheet.

Returns
An int with the index of the sheet.

◆ isActive()

bool XLSheet::isActive ( ) const
Returns

◆ isSelected()

bool XLSheet::isSelected ( ) const

Determine whether the sheet is selected.

Returns

◆ isType()

template<typename SheetType , typename = std::enable_if_t<std::is_same_v<SheetType, XLWorksheet> or std::is_same_v<SheetType, XLChartsheet>>>
bool OpenXLSX::XLSheet::isType ( ) const
inline

Method to get the type of the sheet.

Returns
An XLSheetType enum object with the sheet type.

◆ name()

std::string XLSheet::name ( ) const

Method to retrieve the name of the sheet.

Returns
A std::string with the sheet name.

◆ operator XLChartsheet()

XLSheet::operator XLChartsheet ( ) const
Returns

◆ operator XLWorksheet()

XLSheet::operator XLWorksheet ( ) const
Returns

◆ operator=() [1/2]

XLSheet & OpenXLSX::XLSheet::operator= ( const XLSheet other)
default

Assignment operator.

Returns
A reference to the new object.
Note
The default assignment operator is used, i.e. only shallow copying of pointer data members.

◆ operator=() [2/2]

XLSheet & OpenXLSX::XLSheet::operator= ( XLSheet &&  other)
defaultnoexcept
Parameters
other
Returns

◆ print()

void XLSheet::print ( std::basic_ostream< char > &  ostr) const

Print the XML contents of the XLSheet using the underlying XMLNode print function.

◆ setActive()

bool XLSheet::setActive ( )

◆ setColor()

void XLSheet::setColor ( const XLColor color)
Parameters
color

◆ setIndex()

void XLSheet::setIndex ( uint16_t  index)

Method for setting the index of the sheet. This effectively moves the sheet to a different position.

◆ setName()

void XLSheet::setName ( const std::string &  name)

Method for renaming the sheet.

Parameters
nameA std::string with the new name.

◆ setSelected()

void XLSheet::setSelected ( bool  selected)
Parameters
selected

◆ setVisibility()

void XLSheet::setVisibility ( XLSheetState  state)

Method for setting the state of the sheet.

Parameters
stateAn XLSheetState enum object with the new state.
Bug:
For some reason, this method doesn't work. The data is written correctly to the xml file, but the sheet is not hidden when opening the file in Excel.

◆ visibility()

XLSheetState XLSheet::visibility ( ) const

Method for getting the current visibility state of the sheet.

Returns
An XLSheetState enum object, with the current sheet state.

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