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

A class encapsulating an Excel worksheet. Access to XLWorksheet objects should be via the workbook object. More...

#include <XLWorksheet.hpp>

Inheritance diagram for OpenXLSX::XLWorksheet:
OpenXLSX::XLSheetBase< XLWorksheet > OpenXLSX::XLXmlFile

Public Member Functions

 XLWorksheet ()
 
 XLWorksheet (XLXmlData *xmlData)
 
 ~XLWorksheet ()
 
 XLWorksheet (const XLWorksheet &other)
 
 XLWorksheet (XLWorksheet &&other) noexcept
 
XLWorksheetoperator= (const XLWorksheet &other)
 
XLWorksheetoperator= (XLWorksheet &&other)
 
XLCellAssignable cell (const std::string &ref) const
 
XLCellAssignable cell (const XLCellReference &ref) const
 
XLCellAssignable cell (uint32_t rowNumber, uint16_t columnNumber) const
 
XLCellAssignable cell (XLRowIndex row, XLColIndex col) const
 
XLStreamWriter streamWriter ()
 Starts a high-performance, low-memory stream writer for this worksheet.
 
XLStreamReader streamReader () const
 Create a stream reader for memory efficient reading of large documents.
 
XLCellAssignable findCell (const std::string &ref) const
 
XLCellAssignable findCell (const XLCellReference &ref) const
 
XLCellAssignable findCell (uint32_t rowNumber, uint16_t columnNumber) const
 
std::optional< XLCellpeekCell (const std::string &ref) const
 
std::optional< XLCellpeekCell (const XLCellReference &ref) const
 
std::optional< XLCellpeekCell (uint32_t rowNumber, uint16_t columnNumber) const
 
std::optional< XLCellpeekCell (XLRowIndex row, XLColIndex col) const
 
XLCellRange range () const
 
XLCellRange range (const XLCellReference &topLeft, const XLCellReference &bottomRight) const
 
XLCellRange range (std::string const &topLeft, std::string const &bottomRight) const
 
XLCellRange range (std::string const &rangeReference) const
 
XLRowRange rows () const
 
XLRowRange rows (uint32_t rowCount) const
 
XLRowRange rows (uint32_t firstRow, uint32_t lastRow) const
 
XLRow row (uint32_t rowNumber) const
 
void appendRow (const std::vector< XLCellValue > &values)
 Append a new row with the given values.
 
template<typename T , typename = std::enable_if_t<!std::is_same_v<T, std::vector<XLCellValue>> && std::is_base_of_v<std::bidirectional_iterator_tag, typename std::iterator_traits<typename T::iterator>::iterator_category>, T>>
void appendRow (const T &values)
 Append a new row with the given container of values.
 
XLColumn column (uint16_t columnNumber) const
 
XLColumn column (std::string const &columnRef) const
 
void autoFitColumn (uint16_t columnNumber)
 Automatically adjusts the column width based on the content of its cells.
 
void groupRows (uint32_t rowFirst, uint32_t rowLast, uint8_t outlineLevel=1, bool collapsed=false)
 
void groupColumns (uint16_t colFirst, uint16_t colLast, uint8_t outlineLevel=1, bool collapsed=false)
 
void setAutoFilter (const XLCellRange &range)
 
void clearAutoFilter ()
 
bool hasAutoFilter () const
 
std::string autoFilter () const
 
XLAutoFilter autofilterObject () const
 
void addSortCondition (const std::string &ref, uint16_t colId, bool descending=false)
 Set the sort state for the worksheet.
 
void applyAutoFilter ()
 Evaluates the current autoFilter conditions and hides rows that do not match the criteria. Note: Only basic text/value matching and some simple custom filters are evaluated. Complex dynamic filters might not be supported.
 
XLCellReference lastCell () const noexcept
 
uint16_t columnCount () const noexcept
 
uint32_t rowCount () const noexcept
 
bool deleteRow (uint32_t rowNumber)
 
bool insertRow (uint32_t rowNumber, uint32_t count=1)
 Insert one or more empty rows before the given row number.
 
bool deleteRow (uint32_t rowNumber, uint32_t count)
 Delete one or more rows and shift subsequent rows up.
 
bool insertColumn (uint16_t colNumber, uint16_t count=1)
 Insert one or more empty columns before the given column number.
 
bool deleteColumn (uint16_t colNumber, uint16_t count=1)
 Delete one or more columns and shift subsequent columns left.
 
void updateSheetName (const std::string &oldName, const std::string &newName)
 
void updateDimension ()
 
XLMergeCellsmerges ()
 
XLDataValidationsdataValidations ()
 
XLCellRange mergeCells (XLCellRange const &rangeToMerge, bool emptyHiddenCells=false)
 
XLCellRange mergeCells (const std::string &rangeReference, bool emptyHiddenCells=false)
 
void unmergeCells (XLCellRange const &rangeToMerge)
 
void unmergeCells (const std::string &rangeReference)
 
XLStyleIndex getColumnFormat (uint16_t column) const
 
XLStyleIndex getColumnFormat (const std::string &column) const
 
bool setColumnFormat (uint16_t column, XLStyleIndex cellFormatIndex)
 
bool setColumnFormat (const std::string &column, XLStyleIndex cellFormatIndex)
 
XLStyleIndex getRowFormat (uint16_t row) const
 
bool setRowFormat (uint32_t row, XLStyleIndex cellFormatIndex)
 
XLConditionalFormats conditionalFormats () const
 
void addConditionalFormatting (const std::string &sqref, const XLCfRule &rule)
 
void addConditionalFormatting (const std::string &sqref, const XLCfRule &rule, const XLDxf &dxf)
 
void addConditionalFormatting (const XLCellRange &range, const XLCfRule &rule)
 
void addConditionalFormatting (const XLCellRange &range, const XLCfRule &rule, const XLDxf &dxf)
 
void removeConditionalFormatting (const std::string &sqref)
 
void removeConditionalFormatting (const XLCellRange &range)
 
void clearAllConditionalFormatting ()
 
XLPageMargins pageMargins () const
 
XLPrintOptions printOptions () const
 
XLPageSetup pageSetup () const
 
XLHeaderFooter headerFooter () const
 
void setPrintArea (const std::string &sqref)
 Set the print area for this worksheet.
 
void setPrintTitleRows (uint32_t firstRow, uint32_t lastRow)
 Set rows to repeat at the top of each printed page.
 
void setPrintTitleCols (uint16_t firstCol, uint16_t lastCol)
 Set columns to repeat at the left of each printed page.
 
bool protect (const XLSheetProtectionOptions &options, std::string_view password="")
 Protect the worksheet with granular options.
 
bool protectSheet (bool set=true)
 
bool protectObjects (bool set=true)
 
bool protectScenarios (bool set=true)
 
bool allowInsertColumns (bool set=true)
 
bool allowInsertRows (bool set=true)
 
bool allowDeleteColumns (bool set=true)
 
bool allowDeleteRows (bool set=true)
 
bool allowFormatCells (bool set=true)
 
bool allowFormatColumns (bool set=true)
 
bool allowFormatRows (bool set=true)
 
bool allowInsertHyperlinks (bool set=true)
 
bool allowSort (bool set=true)
 
bool allowAutoFilter (bool set=true)
 
bool allowPivotTables (bool set=true)
 
bool allowSelectLockedCells (bool set=true)
 
bool allowSelectUnlockedCells (bool set=true)
 
bool denyInsertColumns ()
 
bool denyInsertRows ()
 
bool denyDeleteColumns ()
 
bool denyDeleteRows ()
 
bool denyFormatCells ()
 
bool denyFormatColumns ()
 
bool denyFormatRows ()
 
bool denyInsertHyperlinks ()
 
bool denySort ()
 
bool denyAutoFilter ()
 
bool denyPivotTables ()
 
bool denySelectLockedCells ()
 
bool denySelectUnlockedCells ()
 
bool setPasswordHash (std::string hash)
 
bool setPassword (std::string password)
 
bool clearPassword ()
 
bool clearSheetProtection ()
 
bool sheetProtected () const
 
bool objectsProtected () const
 
bool scenariosProtected () const
 
bool insertColumnsAllowed () const
 
bool insertRowsAllowed () const
 
bool deleteColumnsAllowed () const
 
bool deleteRowsAllowed () const
 
bool formatCellsAllowed () const
 
bool formatColumnsAllowed () const
 
bool formatRowsAllowed () const
 
bool insertHyperlinksAllowed () const
 
bool sortAllowed () const
 
bool autoFilterAllowed () const
 
bool pivotTablesAllowed () const
 
bool selectLockedCellsAllowed () const
 
bool selectUnlockedCellsAllowed () const
 
std::string passwordHash () const
 
bool passwordIsSet () const
 
std::string sheetProtectionSummary () const
 
void addSparkline (const std::string &location, const std::string &dataRange, XLSparklineType type=XLSparklineType::Line)
 Add a sparkline to the worksheet.
 
void addSparkline (const std::string &location, const std::string &dataRange, const XLSparklineOptions &options)
 Add a sparkline graph with advanced configuration options.
 
bool hasRelationships () const
 
bool hasDrawing () const
 
bool hasVmlDrawing () const
 
bool hasComments () const
 
bool hasThreadedComments () const
 
bool hasTables () const
 
XLDrawingdrawing ()
 
void addImage (const std::string &name, const std::string &data, uint32_t row, uint32_t col, uint32_t width, uint32_t height, const XLImageOptions &options=XLImageOptions())
 
void addShape (std::string_view cellReference, const XLVectorShapeOptions &options)
 Insert an image at the specified cell with original dimensions (automatic parsing).
 
void addTableSlicer (std::string_view cellReference, const XLTable &table, std::string_view columnName, const XLSlicerOptions &options=XLSlicerOptions())
 Add a slicer connected to a table.
 
void addPivotSlicer (std::string_view cellReference, const XLPivotTable &pivotTable, std::string_view columnName, const XLSlicerOptions &options=XLSlicerOptions())
 Add a slicer connected to a Pivot Table.
 
void insertImage (const std::string &cellReference, const std::string &imagePath)
 
void insertImage (const std::string &cellReference, const std::string &imagePath, const XLImageOptions &options)
 Insert an image with advanced formatting options (scaling, offset, behavior).
 
void addScaledImage (const std::string &name, const std::string &data, uint32_t row, uint32_t col, double scalingFactor=1.0)
 
std::vector< XLDrawingItemimages ()
 
XLChart addChart (XLChartType type, std::string_view name, uint32_t row, uint32_t col, uint32_t width, uint32_t height)
 
XLChart addChart (XLChartType type, const XLChartAnchor &anchor)
 
std::vector< XLPivotTablepivotTables ()
 Retrieves all pivot tables belonging to this worksheet.
 
XLPivotTable addPivotTable (const XLPivotTableOptions &options)
 Create and add a pivot table to this worksheet.
 
bool deletePivotTable (std::string_view name)
 Delete a pivot table by name from this worksheet.
 
XLVmlDrawingvmlDrawing ()
 
XLCommentscomments ()
 
XLThreadedCommentsthreadedComments ()
 
void addNote (std::string_view cellRef, std::string_view text, std::string_view author="")
 Add a comment to a cell seamlessly.
 
void deleteComment (std::string_view cellRef)
 Remove a modern threaded comment (and its replies) from a cell.
 
void deleteNote (std::string_view cellRef)
 Remove a legacy yellow note from a cell.
 
XLThreadedComment addComment (std::string_view cellRef, std::string_view text, std::string_view author="")
 Add a modern threaded comment to a cell seamlessly.
 
XLThreadedComment addReply (const std::string &parentId, const std::string &text, const std::string &author="")
 Add a reply to an existing threaded comment.
 
XLTableCollectiontables ()
 
void addHyperlink (std::string_view cellRef, std::string_view url, std::string_view tooltip="")
 
void addInternalHyperlink (std::string_view cellRef, std::string_view location, std::string_view tooltip="")
 
bool hasHyperlink (std::string_view cellRef) const
 
std::string getHyperlink (std::string_view cellRef) const
 
void removeHyperlink (std::string_view cellRef)
 
bool hasPanes () const
 
void freezePanes (uint16_t column, uint32_t row)
 
void freezePanes (const std::string &topLeftCell)
 Freeze panes at the specified top-left cell. This is a highly ergonomic method. E.g. freezePanes("B2") freezes Row 1 and Column A.
 
void splitPanes (double xSplit, double ySplit, std::string_view topLeftCell="", XLPane activePane=XLPane::BottomRight)
 
void clearPanes ()
 
void setZoom (uint16_t scale)
 
uint16_t zoom () const
 
void insertRowBreak (uint32_t row)
 
void insertColBreak (uint16_t col)
 
void removeRowBreak (uint32_t row)
 
void removeColBreak (uint16_t col)
 
void setSheetViewMode (std::string_view mode)
 
std::string sheetViewMode () const
 
void setShowGridLines (bool show)
 
bool showGridLines () const
 
void setShowRowColHeaders (bool show)
 
bool showRowColHeaders () const
 
void fitToPages (uint32_t fitToWidth, uint32_t fitToHeight)
 
- Public Member Functions inherited from OpenXLSX::XLSheetBase< XLWorksheet >
 XLSheetBase ()
 Constructor.
 
 XLSheetBase (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.
 
 XLSheetBase (const XLSheetBase &other)=default
 The copy constructor.
 
 XLSheetBase (XLSheetBase &&other) noexcept=default
 
 ~XLSheetBase ()=default
 The destructor.
 
XLSheetBaseoperator= (const XLSheetBase &)=default
 Assignment operator.
 
XLSheetBaseoperator= (XLSheetBase &&other) noexcept=default
 
XLSheetState visibility () const
 
void setVisibility (XLSheetState state)
 
XLColor color () const
 
void setColor (const XLColor &color)
 
uint16_t index () const
 look up sheet name via relationshipID, then attempt to match that to a sheet in XLWorkbook::sheet(uint16_t index), looping over index
 
void setIndex (uint16_t index)
 
std::string name () const
 Method to retrieve the name of the sheet.
 
void setName (const std::string &sheetName)
 Method for renaming the sheet.
 
bool isSelected () const
 
void setSelected (bool selected)
 
bool isActive () const
 
bool setActive ()
 
void clone (const std::string &newName)
 Method for cloning the sheet.
 
- 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.
 

Static Public Member Functions

static std::string makeInternalLocation (std::string_view sheetName, std::string_view cellRef)
 

Friends

class XLCell
 
class XLRow
 
class XLWorkbook
 
class XLTableCollection
 
class XLSheetBase< XLWorksheet >
 

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

A class encapsulating an Excel worksheet. Access to XLWorksheet objects should be via the workbook object.

Constructor & Destructor Documentation

◆ XLWorksheet() [1/4]

XLWorksheet::XLWorksheet ( )

The constructor does some slight reconfiguration of the XML file, in order to make parsing easier.

◆ XLWorksheet() [2/4]

XLWorksheet::XLWorksheet ( XLXmlData xmlData)
explicit

◆ ~XLWorksheet()

XLWorksheet::~XLWorksheet ( )
default

◆ XLWorksheet() [3/4]

XLWorksheet::XLWorksheet ( const XLWorksheet other)

◆ XLWorksheet() [4/4]

XLWorksheet::XLWorksheet ( XLWorksheet &&  other)
noexcept

Member Function Documentation

◆ addChart() [1/2]

XLChart XLWorksheet::addChart ( XLChartType  type,
const XLChartAnchor anchor 
)

◆ addChart() [2/2]

XLChart XLWorksheet::addChart ( XLChartType  type,
std::string_view  name,
uint32_t  row,
uint32_t  col,
uint32_t  width,
uint32_t  height 
)

◆ addComment()

XLThreadedComment XLWorksheet::addComment ( std::string_view  cellRef,
std::string_view  text,
std::string_view  author = "" 
)

Add a modern threaded comment to a cell seamlessly.

Parameters
cellRefThe cell reference (e.g. A1).
textThe comment text.
authorThe author of the comment.

◆ addConditionalFormatting() [1/4]

void XLWorksheet::addConditionalFormatting ( const std::string &  sqref,
const XLCfRule rule 
)

◆ addConditionalFormatting() [2/4]

void XLWorksheet::addConditionalFormatting ( const std::string &  sqref,
const XLCfRule rule,
const XLDxf dxf 
)

◆ addConditionalFormatting() [3/4]

void XLWorksheet::addConditionalFormatting ( const XLCellRange range,
const XLCfRule rule 
)

◆ addConditionalFormatting() [4/4]

void XLWorksheet::addConditionalFormatting ( const XLCellRange range,
const XLCfRule rule,
const XLDxf dxf 
)

◆ addHyperlink()

void XLWorksheet::addHyperlink ( std::string_view  cellRef,
std::string_view  url,
std::string_view  tooltip = "" 
)

◆ addImage()

void XLWorksheet::addImage ( const std::string &  name,
const std::string &  data,
uint32_t  row,
uint32_t  col,
uint32_t  width,
uint32_t  height,
const XLImageOptions options = XLImageOptions() 
)

◆ addInternalHyperlink()

void XLWorksheet::addInternalHyperlink ( std::string_view  cellRef,
std::string_view  location,
std::string_view  tooltip = "" 
)

◆ addNote()

void XLWorksheet::addNote ( std::string_view  cellRef,
std::string_view  text,
std::string_view  author = "" 
)

Add a comment to a cell seamlessly.

Parameters
cellRefThe cell reference (e.g. A1).
textThe comment text.
authorThe author of the comment.

◆ addPivotSlicer()

void XLWorksheet::addPivotSlicer ( std::string_view  cellReference,
const XLPivotTable pivotTable,
std::string_view  columnName,
const XLSlicerOptions options = XLSlicerOptions() 
)

Add a slicer connected to a Pivot Table.

Parameters
cellReferenceThe top-left cell where the slicer should be anchored.
pivotTableThe Pivot Table to filter.
columnNameThe exact name of the pivot field (source column name) to filter.
optionsThe visual and naming options for the slicer.

◆ addPivotTable()

XLPivotTable XLWorksheet::addPivotTable ( const XLPivotTableOptions options)

Create and add a pivot table to this worksheet.

Parameters
optionsThe configuration options for the pivot table.
Returns
The created XLPivotTable object.

◆ addReply()

XLThreadedComment XLWorksheet::addReply ( const std::string &  parentId,
const std::string &  text,
const std::string &  author = "" 
)

Add a reply to an existing threaded comment.

Parameters
parentIdThe parent threaded comment ID.
textThe comment text.
authorThe author of the comment.

◆ addScaledImage()

void XLWorksheet::addScaledImage ( const std::string &  name,
const std::string &  data,
uint32_t  row,
uint32_t  col,
double  scalingFactor = 1.0 
)

◆ addShape()

void XLWorksheet::addShape ( std::string_view  cellReference,
const XLVectorShapeOptions options 
)

Insert an image at the specified cell with original dimensions (automatic parsing).

Parameters
cellReferenceThe top-left cell where the image should be anchored (e.g. "B2").
imagePathThe file path to the local image.

◆ addSortCondition()

void XLWorksheet::addSortCondition ( const std::string &  ref,
uint16_t  colId,
bool  descending = false 
)

Set the sort state for the worksheet.

Parameters
refThe cell range to apply the sort state to (e.g. "A1:C10").
colIdThe 0-based column index relative to the range to sort by.
descendingTrue for descending order, false for ascending.

◆ addSparkline() [1/2]

void XLWorksheet::addSparkline ( const std::string &  location,
const std::string &  dataRange,
const XLSparklineOptions options 
)

Add a sparkline graph with advanced configuration options.

Parameters
locationThe cell or range where the sparkline will be rendered (e.g. "F1").
dataRangeThe source data range for the sparkline (e.g. "A1:E1").
optionsA structure containing extensive visual formatting options.

◆ addSparkline() [2/2]

void XLWorksheet::addSparkline ( const std::string &  location,
const std::string &  dataRange,
XLSparklineType  type = XLSparklineType::Line 
)

Add a sparkline to the worksheet.

Parameters
locationThe cell where the sparkline is displayed (e.g., "A1").
dataRangeThe cell range containing the data (e.g., "B1:Z1").
typeThe type of the sparkline (Line, Column, Stacked).

◆ addTableSlicer()

void XLWorksheet::addTableSlicer ( std::string_view  cellReference,
const XLTable table,
std::string_view  columnName,
const XLSlicerOptions options = XLSlicerOptions() 
)

Add a slicer connected to a table.

Parameters
cellReferenceThe top-left cell where the slicer should be anchored (e.g. "D1").
tableThe table to filter.
columnNameThe exact name of the table column to filter.
optionsThe visual and naming options for the slicer.

◆ allowAutoFilter()

bool XLWorksheet::allowAutoFilter ( bool  set = true)

◆ allowDeleteColumns()

bool XLWorksheet::allowDeleteColumns ( bool  set = true)

◆ allowDeleteRows()

bool XLWorksheet::allowDeleteRows ( bool  set = true)

◆ allowFormatCells()

bool XLWorksheet::allowFormatCells ( bool  set = true)

◆ allowFormatColumns()

bool XLWorksheet::allowFormatColumns ( bool  set = true)

◆ allowFormatRows()

bool XLWorksheet::allowFormatRows ( bool  set = true)

◆ allowInsertColumns()

bool XLWorksheet::allowInsertColumns ( bool  set = true)

◆ allowInsertHyperlinks()

bool XLWorksheet::allowInsertHyperlinks ( bool  set = true)

◆ allowInsertRows()

bool XLWorksheet::allowInsertRows ( bool  set = true)

◆ allowPivotTables()

bool XLWorksheet::allowPivotTables ( bool  set = true)

◆ allowSelectLockedCells()

bool XLWorksheet::allowSelectLockedCells ( bool  set = true)

◆ allowSelectUnlockedCells()

bool XLWorksheet::allowSelectUnlockedCells ( bool  set = true)

◆ allowSort()

bool XLWorksheet::allowSort ( bool  set = true)

◆ appendRow() [1/2]

void XLWorksheet::appendRow ( const std::vector< XLCellValue > &  values)

Append a new row with the given values.

Parameters
valuesA vector of XLCellValue items.

◆ appendRow() [2/2]

template<typename T , typename = std::enable_if_t<!std::is_same_v<T, std::vector<XLCellValue>> && std::is_base_of_v<std::bidirectional_iterator_tag, typename std::iterator_traits<typename T::iterator>::iterator_category>, T>>
void OpenXLSX::XLWorksheet::appendRow ( const T &  values)
inline

Append a new row with the given container of values.

Template Parameters
TA container type.
Parameters
valuesThe container of values.

◆ applyAutoFilter()

void XLWorksheet::applyAutoFilter ( )

Evaluates the current autoFilter conditions and hides rows that do not match the criteria. Note: Only basic text/value matching and some simple custom filters are evaluated. Complex dynamic filters might not be supported.

◆ autoFilter()

std::string XLWorksheet::autoFilter ( ) const

◆ autoFilterAllowed()

bool XLWorksheet::autoFilterAllowed ( ) const

◆ autofilterObject()

XLAutoFilter XLWorksheet::autofilterObject ( ) const

◆ autoFitColumn()

void XLWorksheet::autoFitColumn ( uint16_t  columnNumber)

Automatically adjusts the column width based on the content of its cells.

◆ cell() [1/4]

XLCellAssignable XLWorksheet::cell ( const std::string &  ref) const

◆ cell() [2/4]

XLCellAssignable XLWorksheet::cell ( const XLCellReference ref) const

◆ cell() [3/4]

XLCellAssignable XLWorksheet::cell ( uint32_t  rowNumber,
uint16_t  columnNumber 
) const

◆ cell() [4/4]

XLCellAssignable OpenXLSX::XLWorksheet::cell ( XLRowIndex  row,
XLColIndex  col 
) const
inline

◆ clearAllConditionalFormatting()

void XLWorksheet::clearAllConditionalFormatting ( )

◆ clearAutoFilter()

void XLWorksheet::clearAutoFilter ( )

◆ clearPanes()

void XLWorksheet::clearPanes ( )

◆ clearPassword()

bool XLWorksheet::clearPassword ( )

◆ clearSheetProtection()

bool XLWorksheet::clearSheetProtection ( )

◆ column() [1/2]

XLColumn XLWorksheet::column ( std::string const &  columnRef) const

◆ column() [2/2]

XLColumn XLWorksheet::column ( uint16_t  columnNumber) const

◆ columnCount()

uint16_t XLWorksheet::columnCount ( ) const
noexcept

◆ comments()

XLComments & XLWorksheet::comments ( )

◆ conditionalFormats()

XLConditionalFormats XLWorksheet::conditionalFormats ( ) const

◆ dataValidations()

XLDataValidations & XLWorksheet::dataValidations ( )

◆ deleteColumn()

bool XLWorksheet::deleteColumn ( uint16_t  colNumber,
uint16_t  count = 1 
)

Delete one or more columns and shift subsequent columns left.

Parameters
colNumber1-based first column to delete.
countNumber of consecutive columns to delete (default 1).
Returns
true on success.

◆ deleteColumnsAllowed()

bool XLWorksheet::deleteColumnsAllowed ( ) const

◆ deleteComment()

void XLWorksheet::deleteComment ( std::string_view  cellRef)

Remove a modern threaded comment (and its replies) from a cell.

Parameters
cellRefThe cell reference (e.g. A1).

◆ deleteNote()

void XLWorksheet::deleteNote ( std::string_view  cellRef)

Remove a legacy yellow note from a cell.

Parameters
cellRefThe cell reference (e.g. A1).

◆ deletePivotTable()

bool XLWorksheet::deletePivotTable ( std::string_view  name)

Delete a pivot table by name from this worksheet.

Parameters
nameThe name of the pivot table to delete.
Returns
True if successfully deleted, false if not found.

◆ deleteRow() [1/2]

bool XLWorksheet::deleteRow ( uint32_t  rowNumber)

◆ deleteRow() [2/2]

bool XLWorksheet::deleteRow ( uint32_t  rowNumber,
uint32_t  count 
)

Delete one or more rows and shift subsequent rows up.

All subsystems (merges, formulas, drawings, validations, autoFilter) are updated automatically.

Parameters
rowNumber1-based first row to delete.
countNumber of consecutive rows to delete (default 1).
Returns
true on success.

◆ deleteRowsAllowed()

bool XLWorksheet::deleteRowsAllowed ( ) const

◆ denyAutoFilter()

bool OpenXLSX::XLWorksheet::denyAutoFilter ( )
inline

◆ denyDeleteColumns()

bool OpenXLSX::XLWorksheet::denyDeleteColumns ( )
inline

◆ denyDeleteRows()

bool OpenXLSX::XLWorksheet::denyDeleteRows ( )
inline

◆ denyFormatCells()

bool OpenXLSX::XLWorksheet::denyFormatCells ( )
inline

◆ denyFormatColumns()

bool OpenXLSX::XLWorksheet::denyFormatColumns ( )
inline

◆ denyFormatRows()

bool OpenXLSX::XLWorksheet::denyFormatRows ( )
inline

◆ denyInsertColumns()

bool OpenXLSX::XLWorksheet::denyInsertColumns ( )
inline

◆ denyInsertHyperlinks()

bool OpenXLSX::XLWorksheet::denyInsertHyperlinks ( )
inline

◆ denyInsertRows()

bool OpenXLSX::XLWorksheet::denyInsertRows ( )
inline

◆ denyPivotTables()

bool OpenXLSX::XLWorksheet::denyPivotTables ( )
inline

◆ denySelectLockedCells()

bool OpenXLSX::XLWorksheet::denySelectLockedCells ( )
inline

◆ denySelectUnlockedCells()

bool OpenXLSX::XLWorksheet::denySelectUnlockedCells ( )
inline

◆ denySort()

bool OpenXLSX::XLWorksheet::denySort ( )
inline

◆ drawing()

XLDrawing & XLWorksheet::drawing ( )

◆ findCell() [1/3]

XLCellAssignable XLWorksheet::findCell ( const std::string &  ref) const

◆ findCell() [2/3]

XLCellAssignable XLWorksheet::findCell ( const XLCellReference ref) const

◆ findCell() [3/3]

XLCellAssignable XLWorksheet::findCell ( uint32_t  rowNumber,
uint16_t  columnNumber 
) const

◆ fitToPages()

void XLWorksheet::fitToPages ( uint32_t  fitToWidth,
uint32_t  fitToHeight 
)

◆ formatCellsAllowed()

bool XLWorksheet::formatCellsAllowed ( ) const

◆ formatColumnsAllowed()

bool XLWorksheet::formatColumnsAllowed ( ) const

◆ formatRowsAllowed()

bool XLWorksheet::formatRowsAllowed ( ) const

◆ freezePanes() [1/2]

void XLWorksheet::freezePanes ( const std::string &  topLeftCell)

Freeze panes at the specified top-left cell. This is a highly ergonomic method. E.g. freezePanes("B2") freezes Row 1 and Column A.

Parameters
topLeftCellThe cell reference where the scrolling data should start.

◆ freezePanes() [2/2]

void XLWorksheet::freezePanes ( uint16_t  column,
uint32_t  row 
)

◆ getColumnFormat() [1/2]

XLStyleIndex XLWorksheet::getColumnFormat ( const std::string &  column) const

◆ getColumnFormat() [2/2]

XLStyleIndex XLWorksheet::getColumnFormat ( uint16_t  column) const

◆ getHyperlink()

std::string XLWorksheet::getHyperlink ( std::string_view  cellRef) const

◆ getRowFormat()

XLStyleIndex XLWorksheet::getRowFormat ( uint16_t  row) const

◆ groupColumns()

void XLWorksheet::groupColumns ( uint16_t  colFirst,
uint16_t  colLast,
uint8_t  outlineLevel = 1,
bool  collapsed = false 
)

◆ groupRows()

void XLWorksheet::groupRows ( uint32_t  rowFirst,
uint32_t  rowLast,
uint8_t  outlineLevel = 1,
bool  collapsed = false 
)

◆ hasAutoFilter()

bool XLWorksheet::hasAutoFilter ( ) const

◆ hasComments()

bool XLWorksheet::hasComments ( ) const

◆ hasDrawing()

bool XLWorksheet::hasDrawing ( ) const

◆ hasHyperlink()

bool XLWorksheet::hasHyperlink ( std::string_view  cellRef) const

◆ hasPanes()

bool XLWorksheet::hasPanes ( ) const

◆ hasRelationships()

bool XLWorksheet::hasRelationships ( ) const

◆ hasTables()

bool XLWorksheet::hasTables ( ) const

◆ hasThreadedComments()

bool XLWorksheet::hasThreadedComments ( ) const

◆ hasVmlDrawing()

bool XLWorksheet::hasVmlDrawing ( ) const

◆ headerFooter()

XLHeaderFooter XLWorksheet::headerFooter ( ) const

◆ images()

std::vector< XLDrawingItem > XLWorksheet::images ( )

◆ insertColBreak()

void XLWorksheet::insertColBreak ( uint16_t  col)

◆ insertColumn()

bool XLWorksheet::insertColumn ( uint16_t  colNumber,
uint16_t  count = 1 
)

Insert one or more empty columns before the given column number.

Parameters
colNumber1-based column to insert before.
countNumber of columns to insert (default 1).
Returns
true on success.

◆ insertColumnsAllowed()

bool XLWorksheet::insertColumnsAllowed ( ) const

◆ insertHyperlinksAllowed()

bool XLWorksheet::insertHyperlinksAllowed ( ) const

◆ insertImage() [1/2]

void XLWorksheet::insertImage ( const std::string &  cellReference,
const std::string &  imagePath 
)

◆ insertImage() [2/2]

void XLWorksheet::insertImage ( const std::string &  cellReference,
const std::string &  imagePath,
const XLImageOptions options 
)

Insert an image with advanced formatting options (scaling, offset, behavior).

Parameters
cellReferenceThe top-left cell where the image should be anchored (e.g. "B2").
imagePathThe file path to the local image.
optionsAn XLImageOptions struct specifying formatting and behavior.

◆ insertRow()

bool XLWorksheet::insertRow ( uint32_t  rowNumber,
uint32_t  count = 1 
)

Insert one or more empty rows before the given row number.

All rows at rowNumber and below are shifted down. Merged ranges, formulas, drawing anchors, data validations and the autoFilter reference are all updated to reflect the new layout.

Parameters
rowNumber1-based row to insert before.
countNumber of rows to insert (default 1).
Returns
true on success.

◆ insertRowBreak()

void XLWorksheet::insertRowBreak ( uint32_t  row)

◆ insertRowsAllowed()

bool XLWorksheet::insertRowsAllowed ( ) const

◆ lastCell()

XLCellReference XLWorksheet::lastCell ( ) const
noexcept

◆ makeInternalLocation()

std::string XLWorksheet::makeInternalLocation ( std::string_view  sheetName,
std::string_view  cellRef 
)
static

◆ mergeCells() [1/2]

XLCellRange XLWorksheet::mergeCells ( const std::string &  rangeReference,
bool  emptyHiddenCells = false 
)

◆ mergeCells() [2/2]

XLCellRange XLWorksheet::mergeCells ( XLCellRange const &  rangeToMerge,
bool  emptyHiddenCells = false 
)

◆ merges()

XLMergeCells & XLWorksheet::merges ( )

◆ objectsProtected()

bool XLWorksheet::objectsProtected ( ) const

◆ operator=() [1/2]

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

◆ operator=() [2/2]

XLWorksheet & XLWorksheet::operator= ( XLWorksheet &&  other)

◆ pageMargins()

XLPageMargins XLWorksheet::pageMargins ( ) const

◆ pageSetup()

XLPageSetup XLWorksheet::pageSetup ( ) const

◆ passwordHash()

std::string XLWorksheet::passwordHash ( ) const

◆ passwordIsSet()

bool XLWorksheet::passwordIsSet ( ) const

◆ peekCell() [1/4]

std::optional< XLCell > XLWorksheet::peekCell ( const std::string &  ref) const

◆ peekCell() [2/4]

std::optional< XLCell > XLWorksheet::peekCell ( const XLCellReference ref) const

◆ peekCell() [3/4]

std::optional< XLCell > XLWorksheet::peekCell ( uint32_t  rowNumber,
uint16_t  columnNumber 
) const

◆ peekCell() [4/4]

std::optional< XLCell > OpenXLSX::XLWorksheet::peekCell ( XLRowIndex  row,
XLColIndex  col 
) const
inline

◆ pivotTables()

std::vector< XLPivotTable > XLWorksheet::pivotTables ( )

Retrieves all pivot tables belonging to this worksheet.

Returns
A vector of XLPivotTable objects.

◆ pivotTablesAllowed()

bool XLWorksheet::pivotTablesAllowed ( ) const

◆ printOptions()

XLPrintOptions XLWorksheet::printOptions ( ) const

◆ protect()

bool XLWorksheet::protect ( const XLSheetProtectionOptions options,
std::string_view  password = "" 
)

Protect the worksheet with granular options.

Parameters
optionsA structure containing specific protection flags.
passwordOptional password to protect the sheet.
Returns
true if successful.

◆ protectObjects()

bool XLWorksheet::protectObjects ( bool  set = true)

◆ protectScenarios()

bool XLWorksheet::protectScenarios ( bool  set = true)

◆ protectSheet()

bool XLWorksheet::protectSheet ( bool  set = true)

◆ range() [1/4]

XLCellRange XLWorksheet::range ( ) const

◆ range() [2/4]

XLCellRange XLWorksheet::range ( const XLCellReference topLeft,
const XLCellReference bottomRight 
) const

◆ range() [3/4]

XLCellRange XLWorksheet::range ( std::string const &  rangeReference) const

◆ range() [4/4]

XLCellRange XLWorksheet::range ( std::string const &  topLeft,
std::string const &  bottomRight 
) const

◆ removeColBreak()

void XLWorksheet::removeColBreak ( uint16_t  col)

◆ removeConditionalFormatting() [1/2]

void XLWorksheet::removeConditionalFormatting ( const std::string &  sqref)

◆ removeConditionalFormatting() [2/2]

void XLWorksheet::removeConditionalFormatting ( const XLCellRange range)

◆ removeHyperlink()

void XLWorksheet::removeHyperlink ( std::string_view  cellRef)

◆ removeRowBreak()

void XLWorksheet::removeRowBreak ( uint32_t  row)

◆ row()

XLRow XLWorksheet::row ( uint32_t  rowNumber) const

◆ rowCount()

uint32_t XLWorksheet::rowCount ( ) const
noexcept

◆ rows() [1/3]

XLRowRange XLWorksheet::rows ( ) const

◆ rows() [2/3]

XLRowRange XLWorksheet::rows ( uint32_t  firstRow,
uint32_t  lastRow 
) const

◆ rows() [3/3]

XLRowRange XLWorksheet::rows ( uint32_t  rowCount) const

◆ scenariosProtected()

bool XLWorksheet::scenariosProtected ( ) const

◆ selectLockedCellsAllowed()

bool XLWorksheet::selectLockedCellsAllowed ( ) const

◆ selectUnlockedCellsAllowed()

bool XLWorksheet::selectUnlockedCellsAllowed ( ) const

◆ setAutoFilter()

void XLWorksheet::setAutoFilter ( const XLCellRange range)

◆ setColumnFormat() [1/2]

bool XLWorksheet::setColumnFormat ( const std::string &  column,
XLStyleIndex  cellFormatIndex 
)

◆ setColumnFormat() [2/2]

bool XLWorksheet::setColumnFormat ( uint16_t  column,
XLStyleIndex  cellFormatIndex 
)

◆ setPassword()

bool XLWorksheet::setPassword ( std::string  password)

◆ setPasswordHash()

bool XLWorksheet::setPasswordHash ( std::string  hash)

◆ setPrintArea()

void XLWorksheet::setPrintArea ( const std::string &  sqref)

Set the print area for this worksheet.

Parameters
sqrefThe cell range (e.g., "A1:F50").

◆ setPrintTitleCols()

void XLWorksheet::setPrintTitleCols ( uint16_t  firstCol,
uint16_t  lastCol 
)

Set columns to repeat at the left of each printed page.

Parameters
firstColThe first column to repeat (1-based).
lastColThe last column to repeat (1-based).

◆ setPrintTitleRows()

void XLWorksheet::setPrintTitleRows ( uint32_t  firstRow,
uint32_t  lastRow 
)

Set rows to repeat at the top of each printed page.

Parameters
firstRowThe first row to repeat (1-based).
lastRowThe last row to repeat (1-based).

◆ setRowFormat()

bool XLWorksheet::setRowFormat ( uint32_t  row,
XLStyleIndex  cellFormatIndex 
)

◆ setSheetViewMode()

void XLWorksheet::setSheetViewMode ( std::string_view  mode)

◆ setShowGridLines()

void XLWorksheet::setShowGridLines ( bool  show)

◆ setShowRowColHeaders()

void XLWorksheet::setShowRowColHeaders ( bool  show)

◆ setZoom()

void XLWorksheet::setZoom ( uint16_t  scale)

◆ sheetProtected()

bool XLWorksheet::sheetProtected ( ) const

◆ sheetProtectionSummary()

std::string XLWorksheet::sheetProtectionSummary ( ) const

◆ sheetViewMode()

std::string XLWorksheet::sheetViewMode ( ) const

◆ showGridLines()

bool XLWorksheet::showGridLines ( ) const

◆ showRowColHeaders()

bool XLWorksheet::showRowColHeaders ( ) const

◆ sortAllowed()

bool XLWorksheet::sortAllowed ( ) const

◆ splitPanes()

void XLWorksheet::splitPanes ( double  xSplit,
double  ySplit,
std::string_view  topLeftCell = "",
XLPane  activePane = XLPane::BottomRight 
)

◆ streamReader()

XLStreamReader XLWorksheet::streamReader ( ) const

Create a stream reader for memory efficient reading of large documents.

Returns
An XLStreamReader object.

◆ streamWriter()

XLStreamWriter XLWorksheet::streamWriter ( )

Starts a high-performance, low-memory stream writer for this worksheet.

Warning
Initiating a stream writer locks the DOM for this sheet.

◆ tables()

XLTableCollection & XLWorksheet::tables ( )

◆ threadedComments()

XLThreadedComments & XLWorksheet::threadedComments ( )

◆ unmergeCells() [1/2]

void XLWorksheet::unmergeCells ( const std::string &  rangeReference)

◆ unmergeCells() [2/2]

void XLWorksheet::unmergeCells ( XLCellRange const &  rangeToMerge)

◆ updateDimension()

void XLWorksheet::updateDimension ( )

◆ updateSheetName()

void XLWorksheet::updateSheetName ( const std::string &  oldName,
const std::string &  newName 
)

◆ vmlDrawing()

XLVmlDrawing & XLWorksheet::vmlDrawing ( )

◆ zoom()

uint16_t XLWorksheet::zoom ( ) const

Friends And Related Symbol Documentation

◆ XLCell

friend class XLCell
friend

◆ XLRow

friend class XLRow
friend

◆ XLSheetBase< XLWorksheet >

friend class XLSheetBase< XLWorksheet >
friend

◆ XLTableCollection

friend class XLTableCollection
friend

◆ XLWorkbook

friend class XLWorkbook
friend

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