|
OpenXLSX 1.9.1
|
This class encapsulates the concept of a Workbook. It provides access to the individual sheets (worksheets or chartsheets), as well as functionality for adding, deleting, moving and renaming sheets. More...
#include <XLWorkbook.hpp>
Public Member Functions | |
| XLWorkbook ()=default | |
| Default constructor. Creates an empty ('null') XLWorkbook object. | |
| XLWorkbook (XLXmlData *xmlData) | |
| Constructor. Takes a pointer to an XLXmlData object (stored in the parent XLDocument object). | |
| XLWorkbook (const XLWorkbook &other)=default | |
| Copy Constructor. | |
| XLWorkbook (XLWorkbook &&other)=default | |
| Move constructor. | |
| ~XLWorkbook () | |
| Destructor. | |
| XLWorkbook & | operator= (const XLWorkbook &other)=default |
| Copy assignment operator. | |
| XLWorkbook & | operator= (XLWorkbook &&other)=default |
| Move assignment operator. | |
| XLSheet | sheet (uint16_t index) |
| Get the sheet (worksheet or chartsheet) at the given index. | |
| XLSheet | sheet (std::string_view sheetName) |
| Get the sheet (worksheet or chartsheet) with the given name. | |
| XLWorksheet | worksheet (std::string_view sheetName) |
| Get the worksheet with the given name. | |
| XLWorksheet | worksheet (uint16_t index) |
| Get the worksheet at the given index. | |
| XLChartsheet | chartsheet (std::string_view sheetName) |
| Get the chartsheet with the given name. | |
| XLChartsheet | chartsheet (uint16_t index) |
| Get the chartsheet at the given index. | |
| XLDefinedNames | definedNames () |
| Get the defined names collection. | |
| void | deleteSheet (std::string_view sheetName) |
| Delete sheet (worksheet or chartsheet) from the workbook. | |
| void | addWorksheet (std::string_view sheetName) |
| Add a new worksheet. | |
| void | addChartsheet (std::string_view sheetName) |
| void | cloneSheet (std::string_view existingName, std::string_view newName) |
| Clone an existing sheet. | |
| void | setSheetIndex (std::string_view sheetName, unsigned int index) |
| Move a sheet to a new index. | |
| unsigned int | indexOfSheet (std::string_view sheetName) const |
| Get the index of a sheet. | |
| XLSheetType | typeOfSheet (std::string_view sheetName) const |
| Get the type of a sheet. | |
| XLSheetType | typeOfSheet (unsigned int index) const |
| Get the type of a sheet at a given index. | |
| unsigned int | sheetCount () const |
| Get the total number of sheets in the workbook. | |
| unsigned int | worksheetCount () const |
| Get the total number of worksheets in the workbook. | |
| unsigned int | chartsheetCount () const |
| Get the total number of chartsheets in the workbook. | |
| std::vector< std::string > | sheetNames () const |
| Get a list of all sheet names. | |
| std::vector< std::string > | worksheetNames () const |
| Get a list of all worksheet names. | |
| std::vector< std::string > | chartsheetNames () const |
| Get a list of all chartsheet names. | |
| bool | sheetExists (std::string_view sheetName) const |
| Check if a sheet exists. | |
| bool | worksheetExists (std::string_view sheetName) const |
| Check if a worksheet exists. | |
| bool | chartsheetExists (std::string_view sheetName) const |
| Check if a chartsheet exists. | |
| void | updateSheetReferences (std::string_view oldName, std::string_view newName) |
| Update references to a sheet after renaming. | |
| void | deleteNamedRanges () |
| Delete all named ranges. | |
| void | updateWorksheetDimensions () |
| Update the dimension (used range) for all worksheets in the workbook. | |
| void | setFullCalculationOnLoad () |
| Set a flag to force full calculation upon loading the file in Excel. | |
| void | protect (bool lockStructure, bool lockWindows, std::string_view password="") |
| Protect the workbook. | |
| void | unprotect () |
| Unprotect the workbook. | |
| bool | isProtected () const |
| Check if the workbook is protected. | |
| void | print (std::basic_ostream< char > &ostr) const |
| Print the XML contents of the workbook.xml. | |
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. | |
| 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. | |
Friends | |
| class | XLSheet |
| 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} |
This class encapsulates the concept of a Workbook. It provides access to the individual sheets (worksheets or chartsheets), as well as functionality for adding, deleting, moving and renaming sheets.
|
default |
Default constructor. Creates an empty ('null') XLWorkbook object.
|
explicit |
Constructor. Takes a pointer to an XLXmlData object (stored in the parent XLDocument object).
| xmlData | A pointer to the underlying XLXmlData object, which holds the XML data. |
|
default |
Copy Constructor.
| other | The XLWorkbook object to be copied. |
|
default |
Move constructor.
| other | The XLWorkbook to be moved. |
|
default |
Destructor.
| void XLWorkbook::addChartsheet | ( | std::string_view | sheetName | ) |
| void XLWorkbook::addWorksheet | ( | std::string_view | sheetName | ) |
Add a new worksheet.
| sheetName | The name of the new worksheet. |
| XLChartsheet XLWorkbook::chartsheet | ( | std::string_view | sheetName | ) |
Get the chartsheet with the given name.
| sheetName | The name of the desired chartsheet. |
| XLChartsheet XLWorkbook::chartsheet | ( | uint16_t | index | ) |
Get the chartsheet at the given index.
| index | The index (1-based) at which the desired sheet is located. |
| unsigned int XLWorkbook::chartsheetCount | ( | ) | const |
Get the total number of chartsheets in the workbook.
| bool XLWorkbook::chartsheetExists | ( | std::string_view | sheetName | ) | const |
Check if a chartsheet exists.
| std::vector< std::string > XLWorkbook::chartsheetNames | ( | ) | const |
Get a list of all chartsheet names.
| void XLWorkbook::cloneSheet | ( | std::string_view | existingName, |
| std::string_view | newName | ||
| ) |
Clone an existing sheet.
| existingName | The name of the sheet to clone. |
| newName | The name of the new cloned sheet. |
| XLDefinedNames XLWorkbook::definedNames | ( | ) |
Get the defined names collection.
| void XLWorkbook::deleteNamedRanges | ( | ) |
Delete all named ranges.
| void XLWorkbook::deleteSheet | ( | std::string_view | sheetName | ) |
Delete sheet (worksheet or chartsheet) from the workbook.
| sheetName | Name of the sheet to delete. |
| XLException | An exception will be thrown if trying to delete the last worksheet in the workbook |
| unsigned int XLWorkbook::indexOfSheet | ( | std::string_view | sheetName | ) | const |
Get the index of a sheet.
| sheetName | The name of the sheet. |
| bool XLWorkbook::isProtected | ( | ) | const |
Check if the workbook is protected.
|
default |
Copy assignment operator.
|
default |
Move assignment operator.
| void XLWorkbook::print | ( | std::basic_ostream< char > & | ostr | ) | const |
Print the XML contents of the workbook.xml.
| void XLWorkbook::protect | ( | bool | lockStructure, |
| bool | lockWindows, | ||
| std::string_view | password = "" |
||
| ) |
Protect the workbook.
| lockStructure | If true, the structure of the workbook is locked. |
| lockWindows | If true, the windows of the workbook are locked. |
| password | The password to protect the workbook with. |
| void XLWorkbook::setFullCalculationOnLoad | ( | ) |
Set a flag to force full calculation upon loading the file in Excel.
| void XLWorkbook::setSheetIndex | ( | std::string_view | sheetName, |
| unsigned int | index | ||
| ) |
Move a sheet to a new index.
| sheetName | The name of the sheet to move. |
| index | The index (1-based) where the sheet shall be moved to. |
| XLSheet XLWorkbook::sheet | ( | std::string_view | sheetName | ) |
Get the sheet (worksheet or chartsheet) with the given name.
| sheetName | The name of the desired sheet. |
| XLSheet XLWorkbook::sheet | ( | uint16_t | index | ) |
Get the sheet (worksheet or chartsheet) at the given index.
| index | The index at which the desired sheet is located. |
| unsigned int XLWorkbook::sheetCount | ( | ) | const |
Get the total number of sheets in the workbook.
| bool XLWorkbook::sheetExists | ( | std::string_view | sheetName | ) | const |
Check if a sheet exists.
| std::vector< std::string > XLWorkbook::sheetNames | ( | ) | const |
Get a list of all sheet names.
| XLSheetType XLWorkbook::typeOfSheet | ( | std::string_view | sheetName | ) | const |
Get the type of a sheet.
| sheetName | The name of the sheet. |
| XLSheetType XLWorkbook::typeOfSheet | ( | unsigned int | index | ) | const |
Get the type of a sheet at a given index.
| index | The 1-based index. |
| void XLWorkbook::unprotect | ( | ) |
Unprotect the workbook.
| void XLWorkbook::updateSheetReferences | ( | std::string_view | oldName, |
| std::string_view | newName | ||
| ) |
Update references to a sheet after renaming.
| void XLWorkbook::updateWorksheetDimensions | ( | ) |
Update the dimension (used range) for all worksheets in the workbook.
| XLWorksheet XLWorkbook::worksheet | ( | std::string_view | sheetName | ) |
Get the worksheet with the given name.
| sheetName | The name of the desired worksheet. |
| XLWorksheet XLWorkbook::worksheet | ( | uint16_t | index | ) |
Get the worksheet at the given index.
| index | The index (1-based) at which the desired sheet is located. |
| unsigned int XLWorkbook::worksheetCount | ( | ) | const |
Get the total number of worksheets in the workbook.
| bool XLWorkbook::worksheetExists | ( | std::string_view | sheetName | ) | const |
Check if a worksheet exists.
| std::vector< std::string > XLWorkbook::worksheetNames | ( | ) | const |
Get a list of all worksheet names.
|
friend |
|
friend |