Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
fix(sheet): first sheet hidden (#1538)
Univer6123772abbc2
diff --git a/packages/core/src/sheets/workbook.ts b/packages/core/src/sheets/workbook.tsindex 58ee60e87f..e5bf7bb09c 100644--- a/packages/core/src/sheets/workbook.ts+++ b/packages/core/src/sheets/workbook.ts@@ -204,13 +204,25 @@ export class Workbook extends Disposable {*/getActiveSheet(): Worksheet {const currentActive = this.getRawActiveSheet();- if (!currentActive) {- const worksheet = this._worksheets.get(this._snapshot.sheetOrder[0])!;- this.setActiveSheet(worksheet);- return worksheet;+ if (currentActive) {+ return currentActive;}- return currentActive;+ /**+ * If the first sheet is hidden, we should set the first unhidden sheet to be active.+ */+ const sheetOrder = this._snapshot.sheetOrder;+ for (let i = 0, len = sheetOrder.length; i < len; i++) {+ const worksheet = this._worksheets.get(sheetOrder[i]);+ if (worksheet && worksheet.isSheetHidden() !== BooleanNumber.TRUE) {+ this.setActiveSheet(worksheet);+ return worksheet;+ }+ }++ const worksheet = this._worksheets.get(sheetOrder[0])!;+ this.setActiveSheet(worksheet);+ return worksheet;}setActiveSheet(worksheet: Nullable<Worksheet>): void {