From 9ae0d17acb6686d59d59cda6dcfdd8aa5474ef5e Mon Sep 17 00:00:00 2001 From: SkyZhou <46395124+skyzhou95@users.noreply.github.com> Date: Sun, 15 May 2022 15:12:40 +0800 Subject: [PATCH] Add a methon to class Document Add a methon to class Document in order to set sheet to be actived by the index. --- QXlsx/header/xlsxdocument.h | 1 + QXlsx/source/xlsxdocument.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/QXlsx/header/xlsxdocument.h b/QXlsx/header/xlsxdocument.h index faa74e6..0c94a0f 100644 --- a/QXlsx/header/xlsxdocument.h +++ b/QXlsx/header/xlsxdocument.h @@ -100,6 +100,7 @@ public: bool insertSheet(int index, const QString &name = QString(), AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet); bool selectSheet(const QString &name); + bool selectSheet(int index); bool renameSheet(const QString &oldName, const QString &newName); bool copySheet(const QString &srcName, const QString &distName = QString()); bool moveSheet(const QString &srcName, int distIndex); diff --git a/QXlsx/source/xlsxdocument.cpp b/QXlsx/source/xlsxdocument.cpp index a1c8b4f..a695ae8 100644 --- a/QXlsx/source/xlsxdocument.cpp +++ b/QXlsx/source/xlsxdocument.cpp @@ -1204,6 +1204,16 @@ bool Document::selectSheet(const QString &name) return d->workbook->setActiveSheet(sheetNames().indexOf(name)); } +/*! + * \brief Set worksheet whose index is \a index to be active sheet. + * Returns true if success. + */ +bool Document::selectSheet(int index) +{ + Q_D(Document); + return d->workbook->setActiveSheet(index); +} + /*! * Returns the names of worksheets contained in current document. */