11#ifndef OPENXLSX_XLSHEETBASE_HPP
12#define OPENXLSX_XLSHEETBASE_HPP
14#include "OpenXLSX-Exports.hpp"
21#include <shared_mutex>
62 template<
typename T,
typename = std::enable_if_t<std::is_same_v<T, XLWorksheet> or std::is_same_v<T, XLChartsheet>>>
120 const auto state =
parentDoc().execQuery(query).template result<std::string>();
124 else if (state ==
"hidden") {
127 else if (state ==
"veryHidden") {
140 std::unique_lock<std::shared_mutex> lock(
parentDoc().mutex());
141 auto stateString = std::string();
144 stateString =
"visible";
148 stateString =
"hidden";
152 stateString =
"veryHidden";
158 .setParam(
"sheetVisibility", stateString));
166 XLColor color()
const {
return static_cast<const T&
>(*this).getColor_impl(); }
183 return static_cast<uint16_t
>(std::stoi(
parentDoc().execQuery(query).
template result<std::string>()));
192 std::unique_lock<std::shared_mutex> lock(
parentDoc().mutex());
205 return parentDoc().execQuery(query).template result<std::string>();
214 std::unique_lock<std::shared_mutex> lock(
parentDoc().mutex());
217 .setParam(
"sheetName",
name())
218 .setParam(
"newName", sheetName));
225 bool isSelected()
const {
return static_cast<const T&
>(*this).isSelected_impl(); }
231 void setSelected(
bool selected) {
static_cast<T&
>(*this).setSelected_impl(selected); }
237 bool isActive()
const {
return static_cast<const T&
>(*this).isActive_impl(); }
242 bool setActive() {
return static_cast<T&
>(*this).setActive_impl(); }
250 void clone(
const std::string& newName)
Class representing an Excel chartsheet.
Definition XLChartsheet.hpp:25
Definition XLColor.hpp:32
Definition XLCommandQuery.hpp:53
Definition XLCommandQuery.hpp:116
XLQuery & setParam(std::string_view param, T value)
Definition XLCommandQuery.hpp:132
bool setActive()
Definition XLSheetBase.hpp:242
bool isSelected() const
Definition XLSheetBase.hpp:225
std::string name() const
Method to retrieve the name of the sheet.
Definition XLSheetBase.hpp:201
bool isActive() const
Definition XLSheetBase.hpp:237
uint16_t index() const
look up sheet name via relationshipID, then attempt to match that to a sheet in XLWorkbook::sheet(uin...
Definition XLSheetBase.hpp:179
XLSheetBase(const XLSheetBase &other)=default
The copy constructor.
XLColor color() const
Definition XLSheetBase.hpp:166
void setIndex(uint16_t index)
Definition XLSheetBase.hpp:190
void clone(const std::string &newName)
Method for cloning the sheet.
Definition XLSheetBase.hpp:250
void setColor(const XLColor &color)
Definition XLSheetBase.hpp:172
~XLSheetBase()=default
The destructor.
void setVisibility(XLSheetState state)
Definition XLSheetBase.hpp:138
void setName(const std::string &sheetName)
Method for renaming the sheet.
Definition XLSheetBase.hpp:212
XLSheetState visibility() const
Definition XLSheetBase.hpp:116
XLSheetBase & operator=(const XLSheetBase &)=default
Assignment operator.
XLSheetBase & operator=(XLSheetBase &&other) noexcept=default
XLSheetBase()
Constructor.
Definition XLSheetBase.hpp:69
XLSheetBase(XLXmlData *xmlData)
The constructor. There are no default constructor, so all parameters must be provided for constructin...
Definition XLSheetBase.hpp:77
void setSelected(bool selected)
Definition XLSheetBase.hpp:231
XLSheetBase(XLSheetBase &&other) noexcept=default
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 relationshipID() const
This function returns the relationship ID (the ID used in the XLRelationships objects) for the object...
Definition XLXmlFile.cpp:101
XLDocument & parentDoc()
This function provides access to the parent XLDocument object.
Definition XLXmlFile.cpp:61
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
OPENXLSX_EXPORT void setTabSelected(const XMLDocument &xmlDocument, bool selected)
Set the tab selected property to desired value.
Definition XLSheet.cpp:47
XLPaneState
The XLPaneState is an enumeration of the possible states of a pane, e.g. Frozen or Split.
Definition XLSheetBase.hpp:40
@ FrozenSplit
Definition XLSheetBase.hpp:40
@ Frozen
Definition XLSheetBase.hpp:40
@ Split
Definition XLSheetBase.hpp:40
constexpr const bool XLEmptyHiddenCells
Definition XLSheetBase.hpp:30
OPENXLSX_EXPORT XLPaneState XLPaneStateFromString(std::string const &stateString)
inverse of XLPaneStateToString
Definition XLSheet.cpp:93
OPENXLSX_EXPORT XLPane XLPaneFromString(std::string const &paneString)
inverse of XLPaneToString
Definition XLSheet.cpp:126
XLPane
The XLPane is an enumeration of the possible pane identifiers.
Definition XLSheetBase.hpp:45
@ BottomRight
Definition XLSheetBase.hpp:45
@ BottomLeft
Definition XLSheetBase.hpp:45
@ TopLeft
Definition XLSheetBase.hpp:45
OpenXLSX_xml_document XMLDocument
Definition XLXmlParser.hpp:65
XLSheetState
The XLSheetState is an enumeration of the possible (visibility) states, e.g. Visible or Hidden.
Definition XLSheetBase.hpp:35
@ Hidden
Definition XLSheetBase.hpp:35
@ VeryHidden
Definition XLSheetBase.hpp:35
@ Visible
Definition XLSheetBase.hpp:35
@ TopRight
Definition XLChart.hpp:70
@ Hidden
Definition XLChart.hpp:70
OPENXLSX_EXPORT bool tabIsSelected(const XMLDocument &xmlDocument)
Function for checking if the tab is selected.
Definition XLSheet.cpp:61
OPENXLSX_EXPORT std::string XLPaneStateToString(XLPaneState state)
get the correct XLPaneState from the OOXML pane state attribute string
Definition XLSheet.cpp:75
OPENXLSX_EXPORT void setTabColor(const XMLDocument &xmlDocument, const XLColor &color)
Function for setting tab color.
Definition XLSheet.cpp:29
OPENXLSX_EXPORT std::string XLPaneToString(XLPane pane)
get the correct XLPane from the OOXML pane identifier attribute string
Definition XLSheet.cpp:106
@ QuerySheetIndex
Definition XLCommandQuery.hpp:101
@ QuerySheetVisibility
Definition XLCommandQuery.hpp:102
@ QuerySheetName
Definition XLCommandQuery.hpp:100
@ CloneSheet
Definition XLCommandQuery.hpp:45
@ SetSheetIndex
Definition XLCommandQuery.hpp:34
@ SetSheetVisibility
Definition XLCommandQuery.hpp:33
@ SetSheetName
Definition XLCommandQuery.hpp:32