155 std::optional<XLCell> peekCell(
const std::string& ref)
const;
157 std::optional<XLCell> peekCell(uint32_t rowNumber, uint16_t columnNumber)
const;
162 XLCellRange range(std::string
const& topLeft, std::string
const& bottomRight)
const;
163 XLCellRange range(std::string
const& rangeReference)
const;
169 XLRow row(uint32_t rowNumber)
const;
175 void appendRow(
const std::vector<XLCellValue>& values);
183 typename = std::enable_if_t<!std::is_same_v<T, std::vector<XLCellValue>> &&
184 std::is_base_of_v<std::bidirectional_iterator_tag,
185 typename std::iterator_traits<typename T::iterator>::iterator_category>,
188 { row(rowCount() + 1).values() = values; }
190 XLColumn column(uint16_t columnNumber)
const;
191 XLColumn column(std::string
const& columnRef)
const;
196 void autoFitColumn(uint16_t columnNumber);
198 void groupRows(uint32_t rowFirst, uint32_t rowLast, uint8_t outlineLevel = 1,
bool collapsed =
false);
199 void groupColumns(uint16_t colFirst, uint16_t colLast, uint8_t outlineLevel = 1,
bool collapsed =
false);
202 void clearAutoFilter();
203 bool hasAutoFilter()
const;
204 std::string autoFilter()
const;
213 void addSortCondition(
const std::string& ref, uint16_t colId,
bool descending =
false);
220 void applyAutoFilter();
223 uint16_t columnCount() const noexcept;
224 uint32_t rowCount() const noexcept;
226 bool deleteRow(uint32_t rowNumber);
237 bool insertRow(uint32_t rowNumber, uint32_t count = 1);
247 bool deleteRow(uint32_t rowNumber, uint32_t count);
255 bool insertColumn(uint16_t colNumber, uint16_t count = 1);
263 bool deleteColumn(uint16_t colNumber, uint16_t count = 1);
264 void updateSheetName(const
std::
string& oldName, const
std::
string& newName);
265 void updateDimension();
271 XLCellRange mergeCells(const
std::
string& rangeReference,
bool emptyHiddenCells = false);
272 void unmergeCells(
XLCellRange const& rangeToMerge);
273 void unmergeCells(const
std::
string& rangeReference);
277 bool setColumnFormat(uint16_t column,
XLStyleIndex cellFormatIndex);
278 bool setColumnFormat(const
std::
string& column,
XLStyleIndex cellFormatIndex);
281 bool setRowFormat(uint32_t row,
XLStyleIndex cellFormatIndex);
284 void addConditionalFormatting(const
std::
string& sqref, const
XLCfRule& rule);
285 void addConditionalFormatting(const
std::
string& sqref, const
XLCfRule& rule, const
XLDxf& dxf);
289 void removeConditionalFormatting(const
std::
string& sqref);
290 void removeConditionalFormatting(const
XLCellRange& range);
291 void clearAllConditionalFormatting();
302 void setPrintArea(const
std::
string& sqref);
326 bool protectSheet(
bool set = true);
327 bool protectObjects(
bool set = true);
328 bool protectScenarios(
bool set = true);
330 bool allowInsertColumns(
bool set = true);
331 bool allowInsertRows(
bool set = true);
332 bool allowDeleteColumns(
bool set = true);
333 bool allowDeleteRows(
bool set = true);
334 bool allowFormatCells(
bool set = true);
335 bool allowFormatColumns(
bool set = true);
336 bool allowFormatRows(
bool set = true);
337 bool allowInsertHyperlinks(
bool set = true);
338 bool allowSort(
bool set = true);
339 bool allowAutoFilter(
bool set = true);
340 bool allowPivotTables(
bool set = true);
341 bool allowSelectLockedCells(
bool set = true);
342 bool allowSelectUnlockedCells(
bool set = true);
344 bool denyInsertColumns() {
return allowInsertColumns(
false); }
358 bool setPasswordHash(std::string hash);
359 bool setPassword(std::string password);
360 bool clearPassword();
361 bool clearSheetProtection();
363 bool sheetProtected()
const;
364 bool objectsProtected()
const;
365 bool scenariosProtected()
const;
367 bool insertColumnsAllowed()
const;
368 bool insertRowsAllowed()
const;
369 bool deleteColumnsAllowed()
const;
370 bool deleteRowsAllowed()
const;
371 bool formatCellsAllowed()
const;
372 bool formatColumnsAllowed()
const;
373 bool formatRowsAllowed()
const;
374 bool insertHyperlinksAllowed()
const;
375 bool sortAllowed()
const;
376 bool autoFilterAllowed()
const;
377 bool pivotTablesAllowed()
const;
378 bool selectLockedCellsAllowed()
const;
379 bool selectUnlockedCellsAllowed()
const;
381 std::string passwordHash()
const;
382 bool passwordIsSet()
const;
383 std::string sheetProtectionSummary()
const;
391 void addSparkline(
const std::string& location,
const std::string& dataRange,
XLSparklineType type = XLSparklineType::Line);
399 void addSparkline(
const std::string& location,
const std::string& dataRange,
const XLSparklineOptions& options);
401 bool hasRelationships()
const;
402 bool hasDrawing()
const;
403 bool hasVmlDrawing()
const;
404 bool hasComments()
const;
405 bool hasThreadedComments()
const;
406 bool hasTables()
const;
409 void addImage(
const std::string& name,
410 const std::string& data,
432 void addTableSlicer(std::string_view cellReference,
434 std::string_view columnName,
444 void addPivotSlicer(std::string_view cellReference,
446 std::string_view columnName,
449 void insertImage(
const std::string& cellReference,
const std::string& imagePath);
457 void insertImage(
const std::string& cellReference,
const std::string& imagePath,
const XLImageOptions& options);
458 void addScaledImage(
const std::string& name,
const std::string& data, uint32_t row, uint32_t col,
double scalingFactor = 1.0);
459 std::vector<XLDrawingItem> images();
461 XLChart addChart(
XLChartType type, std::string_view name, uint32_t row, uint32_t col, uint32_t width, uint32_t height);
468 std::vector<XLPivotTable> pivotTables();
482 bool deletePivotTable(std::string_view name);
493 void addNote(std::string_view cellRef, std::string_view text, std::string_view author =
"");
499 void deleteComment(std::string_view cellRef);
505 void deleteNote(std::string_view cellRef);
513 XLThreadedComment addComment(std::string_view cellRef, std::string_view text, std::string_view author =
"");
521 XLThreadedComment addReply(
const std::string& parentId,
const std::string& text,
const std::string& author =
"");
525 void addHyperlink(std::string_view cellRef, std::string_view url, std::string_view tooltip =
"");
526 void addInternalHyperlink(std::string_view cellRef, std::string_view location, std::string_view tooltip =
"");
527 [[nodiscard]]
bool hasHyperlink(std::string_view cellRef)
const;
528 [[nodiscard]] std::string getHyperlink(std::string_view cellRef)
const;
529 void removeHyperlink(std::string_view cellRef);
531 [[nodiscard]]
bool hasPanes()
const;
532 void freezePanes(uint16_t column, uint32_t row);
539 void freezePanes(
const std::string& topLeftCell);
541 void splitPanes(
double xSplit,
double ySplit, std::string_view topLeftCell =
"",
XLPane activePane = XLPane::BottomRight);
544 void setZoom(uint16_t scale);
545 [[nodiscard]] uint16_t zoom()
const;
547 void insertRowBreak(uint32_t row);
548 void insertColBreak(uint16_t col);
549 void removeRowBreak(uint32_t row);
550 void removeColBreak(uint16_t col);
552 void setSheetViewMode(std::string_view mode);
553 [[nodiscard]] std::string sheetViewMode()
const;
555 void setShowGridLines(
bool show);
556 [[nodiscard]]
bool showGridLines()
const;
558 void setShowRowColHeaders(
bool show);
559 [[nodiscard]]
bool showRowColHeaders()
const;
561 void fitToPages(uint32_t fitToWidth, uint32_t fitToHeight);
563 [[nodiscard]]
static std::string makeInternalLocation(std::string_view sheetName, std::string_view cellRef);
566 uint16_t sheetXmlNumber()
const;
570 void setColor_impl(
const XLColor& color);
571 bool isSelected_impl()
const;
572 void setSelected_impl(
bool selected);
573 bool isActive_impl()
const;
574 bool setActive_impl();
576 XMLNode prepareSheetViewForPanes();
585 [[nodiscard]]
static std::string
586 shiftCellRef(std::string_view ref, int32_t rowDelta, int32_t colDelta, uint32_t fromRow, uint16_t fromCol);
589 [[nodiscard]]
static std::string
590 shiftFormulaRefs(std::string_view formula, int32_t rowDelta, int32_t colDelta, uint32_t fromRow, uint16_t fromCol);
593 void shiftSheetDataRows(int32_t delta, uint32_t fromRow);
596 void shiftSheetDataCols(int32_t delta, uint16_t fromCol);
599 void shiftColsNode(int32_t delta, uint16_t fromCol);
602 void shiftFormulas(int32_t rowDelta, int32_t colDelta, uint32_t fromRow, uint16_t fromCol);
605 void shiftDrawingAnchors(int32_t rowDelta, int32_t colDelta, uint32_t fromRow, uint16_t fromCol);
608 void shiftDataValidations(int32_t rowDelta, int32_t colDelta, uint32_t fromRow, uint16_t fromCol);
611 void shiftAutoFilter(int32_t rowDelta, int32_t colDelta, uint32_t fromRow, uint16_t fromCol);
614 std::unique_ptr<XLWorksheetImpl> m_impl;
618 mutable uint32_t m_hintRowNumber{0};
619 mutable XMLNode m_hintRowNode{};
620 mutable uint16_t m_hintColNumber{0};
621 mutable XMLNode m_hintCellNode{};