159 std::optional<XLCell> peekCell(
const std::string& ref)
const;
161 std::optional<XLCell> peekCell(uint32_t rowNumber, uint16_t columnNumber)
const;
166 XLCellRange range(std::string
const& topLeft, std::string
const& bottomRight)
const;
167 XLCellRange range(std::string
const& rangeReference)
const;
173 XLRow row(uint32_t rowNumber)
const;
179 void appendRow(
const std::vector<XLCellValue>& values);
187 typename = std::enable_if_t<!std::is_same_v<T, std::vector<XLCellValue>> &&
188 std::is_base_of_v<std::bidirectional_iterator_tag,
189 typename std::iterator_traits<typename T::iterator>::iterator_category>,
192 { row(rowCount() + 1).values() = values; }
194 XLColumn column(uint16_t columnNumber)
const;
195 XLColumn column(std::string
const& columnRef)
const;
200 void autoFitColumn(uint16_t columnNumber);
202 void groupRows(uint32_t rowFirst, uint32_t rowLast, uint8_t outlineLevel = 1,
bool collapsed =
false);
203 void groupColumns(uint16_t colFirst, uint16_t colLast, uint8_t outlineLevel = 1,
bool collapsed =
false);
206 void clearAutoFilter();
207 bool hasAutoFilter()
const;
208 std::string autoFilter()
const;
217 void addSortCondition(
const std::string& ref, uint16_t colId,
bool descending =
false);
224 void applyAutoFilter();
227 uint16_t columnCount() const noexcept;
228 uint32_t rowCount() const noexcept;
230 bool deleteRow(uint32_t rowNumber);
241 bool insertRow(uint32_t rowNumber, uint32_t count = 1);
251 bool deleteRow(uint32_t rowNumber, uint32_t count);
259 bool insertColumn(uint16_t colNumber, uint16_t count = 1);
267 bool deleteColumn(uint16_t colNumber, uint16_t count = 1);
268 void updateSheetName(const
std::
string& oldName, const
std::
string& newName);
269 void updateDimension();
275 XLCellRange mergeCells(const
std::
string& rangeReference,
bool emptyHiddenCells = false);
276 void unmergeCells(
XLCellRange const& rangeToMerge);
277 void unmergeCells(const
std::
string& rangeReference);
281 bool setColumnFormat(uint16_t column,
XLStyleIndex cellFormatIndex);
282 bool setColumnFormat(const
std::
string& column,
XLStyleIndex cellFormatIndex);
285 bool setRowFormat(uint32_t row,
XLStyleIndex cellFormatIndex);
288 void addConditionalFormatting(const
std::
string& sqref, const
XLCfRule& rule);
289 void addConditionalFormatting(const
std::
string& sqref, const
XLCfRule& rule, const
XLDxf& dxf);
293 void removeConditionalFormatting(const
std::
string& sqref);
294 void removeConditionalFormatting(const
XLCellRange& range);
295 void clearAllConditionalFormatting();
306 void setPrintArea(const
std::
string& sqref);
330 bool protectSheet(
bool set = true);
331 bool protectObjects(
bool set = true);
332 bool protectScenarios(
bool set = true);
334 bool allowInsertColumns(
bool set = true);
335 bool allowInsertRows(
bool set = true);
336 bool allowDeleteColumns(
bool set = true);
337 bool allowDeleteRows(
bool set = true);
338 bool allowFormatCells(
bool set = true);
339 bool allowFormatColumns(
bool set = true);
340 bool allowFormatRows(
bool set = true);
341 bool allowInsertHyperlinks(
bool set = true);
342 bool allowSort(
bool set = true);
343 bool allowAutoFilter(
bool set = true);
344 bool allowPivotTables(
bool set = true);
345 bool allowSelectLockedCells(
bool set = true);
346 bool allowSelectUnlockedCells(
bool set = true);
348 bool denyInsertColumns() {
return allowInsertColumns(
false); }
362 bool setPasswordHash(std::string hash);
363 bool setPassword(std::string password);
364 bool clearPassword();
365 bool clearSheetProtection();
367 bool sheetProtected()
const;
368 bool objectsProtected()
const;
369 bool scenariosProtected()
const;
371 bool insertColumnsAllowed()
const;
372 bool insertRowsAllowed()
const;
373 bool deleteColumnsAllowed()
const;
374 bool deleteRowsAllowed()
const;
375 bool formatCellsAllowed()
const;
376 bool formatColumnsAllowed()
const;
377 bool formatRowsAllowed()
const;
378 bool insertHyperlinksAllowed()
const;
379 bool sortAllowed()
const;
380 bool autoFilterAllowed()
const;
381 bool pivotTablesAllowed()
const;
382 bool selectLockedCellsAllowed()
const;
383 bool selectUnlockedCellsAllowed()
const;
385 std::string passwordHash()
const;
386 bool passwordIsSet()
const;
387 std::string sheetProtectionSummary()
const;
395 void addSparkline(
const std::string& location,
const std::string& dataRange,
XLSparklineType type = XLSparklineType::Line);
403 void addSparkline(
const std::string& location,
const std::string& dataRange,
const XLSparklineOptions& options);
405 bool hasRelationships()
const;
406 bool hasDrawing()
const;
407 bool hasVmlDrawing()
const;
408 bool hasComments()
const;
409 bool hasThreadedComments()
const;
410 bool hasTables()
const;
413 void addImage(
const std::string& name,
414 const std::string& data,
437 void addTableSlicer(std::string_view cellReference,
439 std::string_view columnName,
450 void addPivotSlicer(std::string_view cellReference,
452 std::string_view columnName,
481 void deleteSlicer(
const std::string& name);
483 void insertImage(
const std::string& cellReference,
const std::string& imagePath);
491 void insertImage(
const std::string& cellReference,
const std::string& imagePath,
const XLImageOptions& options);
492 void addScaledImage(
const std::string& name,
const std::string& data, uint32_t row, uint32_t col,
double scalingFactor = 1.0);
493 std::vector<XLDrawingItem> images();
495 XLChart addChart(
XLChartType type, std::string_view name, uint32_t row, uint32_t col, uint32_t width, uint32_t height);
502 std::vector<XLPivotTable> pivotTables();
516 bool deletePivotTable(std::string_view name);
527 void addNote(std::string_view cellRef, std::string_view text, std::string_view author =
"");
533 void deleteComment(std::string_view cellRef);
539 void deleteNote(std::string_view cellRef);
547 XLThreadedComment addComment(std::string_view cellRef, std::string_view text, std::string_view author =
"");
555 XLThreadedComment addReply(
const std::string& parentId,
const std::string& text,
const std::string& author =
"");
559 void addHyperlink(std::string_view cellRef, std::string_view url, std::string_view tooltip =
"");
560 void addInternalHyperlink(std::string_view cellRef, std::string_view location, std::string_view tooltip =
"");
561 [[nodiscard]]
bool hasHyperlink(std::string_view cellRef)
const;
562 [[nodiscard]] std::string getHyperlink(std::string_view cellRef)
const;
563 void removeHyperlink(std::string_view cellRef);
565 [[nodiscard]]
bool hasPanes()
const;
566 void freezePanes(uint16_t column, uint32_t row);
573 void freezePanes(
const std::string& topLeftCell);
575 void splitPanes(
double xSplit,
double ySplit, std::string_view topLeftCell =
"",
XLPane activePane = XLPane::BottomRight);
578 void setZoom(uint16_t scale);
579 [[nodiscard]] uint16_t zoom()
const;
581 void insertRowBreak(uint32_t row);
582 void insertColBreak(uint16_t col);
583 void removeRowBreak(uint32_t row);
584 void removeColBreak(uint16_t col);
586 void setSheetViewMode(std::string_view mode);
587 [[nodiscard]] std::string sheetViewMode()
const;
589 void setShowGridLines(
bool show);
590 [[nodiscard]]
bool showGridLines()
const;
592 void setShowRowColHeaders(
bool show);
593 [[nodiscard]]
bool showRowColHeaders()
const;
595 void fitToPages(uint32_t fitToWidth, uint32_t fitToHeight);
597 [[nodiscard]]
static std::string makeInternalLocation(std::string_view sheetName, std::string_view cellRef);
600 uint16_t sheetXmlNumber()
const;
604 void setColor_impl(
const XLColor& color);
605 bool isSelected_impl()
const;
606 void setSelected_impl(
bool selected);
607 bool isActive_impl()
const;
608 bool setActive_impl();
610 XMLNode prepareSheetViewForPanes();
619 [[nodiscard]]
static std::string
620 shiftCellRef(std::string_view ref, int32_t rowDelta, int32_t colDelta, uint32_t fromRow, uint16_t fromCol);
623 [[nodiscard]]
static std::string
624 shiftFormulaRefs(std::string_view formula, int32_t rowDelta, int32_t colDelta, uint32_t fromRow, uint16_t fromCol);
627 void shiftSheetDataRows(int32_t delta, uint32_t fromRow);
630 void shiftSheetDataCols(int32_t delta, uint16_t fromCol);
633 void shiftColsNode(int32_t delta, uint16_t fromCol);
636 void shiftFormulas(int32_t rowDelta, int32_t colDelta, uint32_t fromRow, uint16_t fromCol);
639 void shiftDrawingAnchors(int32_t rowDelta, int32_t colDelta, uint32_t fromRow, uint16_t fromCol);
642 void shiftDataValidations(int32_t rowDelta, int32_t colDelta, uint32_t fromRow, uint16_t fromCol);
645 void shiftAutoFilter(int32_t rowDelta, int32_t colDelta, uint32_t fromRow, uint16_t fromCol);
648 std::unique_ptr<XLWorksheetImpl> m_impl;
652 mutable uint32_t m_hintRowNumber{0};
653 mutable XMLNode m_hintRowNode{};
654 mutable uint16_t m_hintColNumber{0};
655 mutable XMLNode m_hintCellNode{};
658 mutable uint16_t m_maxColumn{0};
659 mutable bool m_dimensionDirty{
true};