11#ifndef OPENXLSX_XLWORKBOOK_HPP
12#define OPENXLSX_XLWORKBOOK_HPP
16# pragma warning(disable : 4251)
17# pragma warning(disable : 4275)
28#include "OpenXLSX-Exports.hpp"
51 std::string
name()
const;
66 bool valid()
const {
return !m_node.empty(); }
82 void remove(std::string_view name, std::optional<uint32_t> localSheetId = std::nullopt);
83 XLDefinedName get(std::string_view name, std::optional<uint32_t> localSheetId = std::nullopt)
const;
84 std::vector<XLDefinedName>
all()
const;
85 bool exists(std::string_view name, std::optional<uint32_t> localSheetId = std::nullopt)
const;
209 void cloneSheet(std::string_view existingName, std::string_view newName);
224 void setSheetIndex(std::string_view sheetName,
unsigned int index);
231 unsigned int indexOfSheet(std::string_view sheetName)
const;
280 bool sheetExists(std::string_view sheetName)
const;
325 void protect(
bool lockStructure,
bool lockWindows, std::string_view password =
"");
340 void print(std::basic_ostream<char>& ostr)
const;
346 uint16_t createInternalSheetID();
351 std::string sheetID(std::string_view sheetName);
356 std::string sheetName(std::string_view sheetID)
const;
361 std::string sheetVisibility(std::string_view sheetID)
const;
366 void prepareSheetMetadata(std::string_view sheetName, uint16_t internalID, std::string_view sheetPath =
"");
371 void setSheetName(std::string_view sheetRID, std::string_view newName);
376 void setSheetVisibility(std::string_view sheetRID, std::string_view state);
381 bool sheetIsActive(std::string_view sheetRID)
const;
386 bool setSheetActive(std::string_view sheetRID);
391 bool isVisibleState(std::string_view state)
const;
396 bool isVisible(
XMLNode const& sheetNode)
const;
Class representing an Excel chartsheet.
Definition XLChartsheet.hpp:25
A class representing a single defined name in a workbook.
Definition XLWorkbook.hpp:46
bool valid() const
Definition XLWorkbook.hpp:66
void setRefersTo(std::string_view formula)
Definition XLWorkbook.cpp:63
std::string name() const
Definition XLWorkbook.cpp:59
void setLocalSheetId(uint32_t id)
Definition XLWorkbook.cpp:72
std::string refersTo() const
Definition XLWorkbook.cpp:62
std::string comment() const
Definition XLWorkbook.cpp:87
void setComment(std::string_view comment)
Definition XLWorkbook.cpp:88
bool hidden() const
Definition XLWorkbook.cpp:79
std::optional< uint32_t > localSheetId() const
Definition XLWorkbook.cpp:65
void setHidden(bool hidden)
Definition XLWorkbook.cpp:80
void setName(std::string_view name)
Definition XLWorkbook.cpp:60
A class representing the collection of defined names in a workbook.
Definition XLWorkbook.hpp:76
XLDefinedName get(std::string_view name, std::optional< uint32_t > localSheetId=std::nullopt) const
Definition XLWorkbook.cpp:125
XLDefinedName append(std::string_view name, std::string_view formula, std::optional< uint32_t > localSheetId=std::nullopt)
Definition XLWorkbook.cpp:97
size_t count() const
Definition XLWorkbook.cpp:150
bool exists(std::string_view name, std::optional< uint32_t > localSheetId=std::nullopt) const
Definition XLWorkbook.cpp:148
void remove(std::string_view name, std::optional< uint32_t > localSheetId=std::nullopt)
Definition XLWorkbook.cpp:106
std::vector< XLDefinedName > all() const
Definition XLWorkbook.cpp:141
The XLAbstractSheet is a generalized sheet class, which functions as superclass for specialized class...
Definition XLSheet.hpp:40
XLDefinedNames definedNames()
Get the defined names collection.
Definition XLWorkbook.cpp:210
void cloneSheet(std::string_view existingName, std::string_view newName)
Clone an existing sheet.
Definition XLWorkbook.cpp:285
XLWorkbook & operator=(XLWorkbook &&other)=default
Move assignment operator.
void protect(bool lockStructure, bool lockWindows, std::string_view password="")
Protect the workbook.
Definition XLWorkbook.cpp:779
void updateWorksheetDimensions()
Update the dimension (used range) for all worksheets in the workbook.
Definition XLWorkbook.cpp:737
bool chartsheetExists(std::string_view sheetName) const
Check if a chartsheet exists.
Definition XLWorkbook.cpp:706
XLWorkbook & operator=(const XLWorkbook &other)=default
Copy assignment operator.
XLChartsheet chartsheet(std::string_view sheetName)
Get the chartsheet with the given name.
Definition XLWorkbook.cpp:207
std::vector< std::string > worksheetNames() const
Get a list of all worksheet names.
Definition XLWorkbook.cpp:669
friend class XLSheet
Definition XLWorkbook.hpp:98
bool worksheetExists(std::string_view sheetName) const
Check if a worksheet exists.
Definition XLWorkbook.cpp:700
unsigned int indexOfSheet(std::string_view sheetName) const
Get the index of a sheet.
Definition XLWorkbook.cpp:591
void unprotect()
Unprotect the workbook.
Definition XLWorkbook.cpp:800
bool sheetExists(std::string_view sheetName) const
Check if a sheet exists.
Definition XLWorkbook.cpp:697
unsigned int chartsheetCount() const
Get the total number of chartsheets in the workbook.
Definition XLWorkbook.cpp:647
void print(std::basic_ostream< char > &ostr) const
Print the XML contents of the workbook.xml.
Definition XLWorkbook.cpp:804
bool isProtected() const
Check if the workbook is protected.
Definition XLWorkbook.cpp:802
void compactStyles()
Compact and deduplicate all cell formats across all worksheets in the workbook.
Definition XLWorkbook.cpp:858
void setFullCalculationOnLoad()
Set a flag to force full calculation upon loading the file in Excel.
Definition XLWorkbook.cpp:763
void updateSheetReferences(std::string_view oldName, std::string_view newName)
Update references to a sheet after renaming.
Definition XLWorkbook.cpp:712
unsigned int worksheetCount() const
Get the total number of worksheets in the workbook.
Definition XLWorkbook.cpp:634
XLWorksheet worksheet(std::string_view sheetName)
Get the worksheet with the given name.
Definition XLWorkbook.cpp:205
std::vector< std::string > sheetNames() const
Get a list of all sheet names.
Definition XLWorkbook.cpp:660
XLSheet sheet(uint16_t index)
Get the sheet (worksheet or chartsheet) at the given index.
Definition XLWorkbook.cpp:179
std::vector< std::string > chartsheetNames() const
Get a list of all chartsheet names.
Definition XLWorkbook.cpp:683
void deleteNamedRanges()
Delete all named ranges.
Definition XLWorkbook.cpp:218
friend class XLDocument
Definition XLWorkbook.hpp:99
void deleteSheet(std::string_view sheetName)
Delete sheet (worksheet or chartsheet) from the workbook.
Definition XLWorkbook.cpp:220
unsigned int sheetCount() const
Get the total number of sheets in the workbook.
Definition XLWorkbook.cpp:625
XLWorkbook()=default
Default constructor. Creates an empty ('null') XLWorkbook object.
void addChartsheet(std::string_view sheetName)
Definition XLWorkbook.cpp:272
XLWorkbook(const XLWorkbook &other)=default
Copy Constructor.
XLWorkbook(XLWorkbook &&other)=default
Move constructor.
void setSheetIndex(std::string_view sheetName, unsigned int index)
Move a sheet to a new index.
Definition XLWorkbook.cpp:517
void addWorksheet(std::string_view sheetName)
Add a new worksheet.
Definition XLWorkbook.cpp:258
XLSheetType typeOfSheet(std::string_view sheetName) const
Get the type of a sheet.
Definition XLWorkbook.cpp:604
A class encapsulating an Excel worksheet. Access to XLWorksheet objects should be via the workbook ob...
Definition XLWorksheet.hpp:132
The XLXmlData class encapsulates the properties and behaviour of the .xml files in an ....
Definition XLXmlData.hpp:79
std::string xmlData(XLXmlSavingDeclaration savingDeclaration=XLXmlSavingDeclaration{}) const
Method for getting the XML data represented by the object.
Definition XLXmlFile.cpp:49
XLXmlFile()=default
Default constructor.
Definition IXLCellProvider.hpp:24
XLSheetType
Enumeration of the different types of sheets.
Definition XLWorkbook.hpp:40
@ Worksheet
Definition XLContentTypes.hpp:42
@ Chartsheet
Definition XLContentTypes.hpp:43
@ Macrosheet
Definition XLRelationships.hpp:76
@ Dialogsheet
Definition XLRelationships.hpp:75
OpenXLSX_xml_node XMLNode
Definition XLXmlParser.hpp:64