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. */