{"record":{"id":"f687586fbee0ec07","repo":"qax-os/excelize","slug":"group-worksheet-must-contain-an-active-worksheet","errorCode":null,"errorMessage":"group worksheet must contain an active worksheet","messagePattern":"group worksheet must contain an active worksheet","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":87,"sourceCode":"\t// ErrFillGradientShading defined the error message on receive an invalid\n\t// fill shading for 'gradient' type.\n\tErrFillGradientShading = errors.New(\"fill shading value must be between 0 and 16 for 'gradient' type\")\n\t// ErrFillPatternColor defined the error message on receive an invalid fill\n\t// color for 'pattern' type.\n\tErrFillPatternColor = errors.New(\"fill color value must be empty or an array of one color for 'pattern' type\")\n\t// ErrFillPattern defined the error message on receive an invalid fill\n\t// pattern.\n\tErrFillPattern = errors.New(\"fill pattern value must be between 0 and 18\")\n\t// ErrFontLength defined the error message on the length of the font\n\t// family name overflow.\n\tErrFontLength = fmt.Errorf(\"the length of the font family name must be less than or equal to %d\", MaxFontFamilyLength)\n\t// ErrFontSize defined the error message on the size of the font is invalid.\n\tErrFontSize = fmt.Errorf(\"font size must be an integer from %d to %d points\", MinFontSize, MaxFontSize)\n\t// ErrFormControlValue defined the error message for receiving a scroll\n\t// value exceeds limit.\n\tErrFormControlValue = fmt.Errorf(\"scroll value must be an integer from 0 to %d\", MaxFormControlValue)\n\t// ErrGroupSheets defined the error message on group sheets.\n\tErrGroupSheets = errors.New(\"group worksheet must contain an active worksheet\")\n\t// ErrImgExt defined the error message on receive an unsupported image\n\t// extension.\n\tErrImgExt = errors.New(\"unsupported image extension\")\n\t// ErrInvalidFormula defined the error message on receive an invalid\n\t// formula.\n\tErrInvalidFormula = errors.New(\"formula not valid\")\n\t// ErrMaxFilePathLength defined the error message on receive the file path\n\t// length overflow.\n\tErrMaxFilePathLength = fmt.Errorf(\"file path length exceeds maximum limit %d characters\", MaxFilePathLength)\n\t// ErrMaxRowHeight defined the error message on receive an invalid row\n\t// height.\n\tErrMaxRowHeight = fmt.Errorf(\"the height of the row must be less than or equal to %d points\", MaxRowHeight)\n\t// ErrMaxRows defined the error message on receive a row number exceeds\n\t// maximum limit.\n\tErrMaxRows = errors.New(\"row number exceeds maximum limit\")\n\t// ErrNameLength defined the error message on receiving the defined name or\n\t// table name length exceeds the limit.\n\tErrNameLength = fmt.Errorf(\"the name length exceeds the %d characters limit\", MaxFieldLength)","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L69-L105","documentation":"ErrGroupSheets is returned when grouping worksheets (GroupSheets) because the selection does not include the workbook's active sheet. Excel requires that a group of worksheets always contains the currently active worksheet.","triggerScenarios":"Calling f.GroupSheets([]string{\"Sheet1\", \"Sheet2\"}) when the workbook's active sheet is Sheet3 (or another sheet not in the list).","commonSituations":"Grouping sheets by name after the user or earlier code changed the active tab, or grouping a subset of sheets that accidentally excludes the active one.","solutions":["Include the currently active sheet in the list passed to GroupSheets (check f.GetActiveSheetName()).","Call f.SetActiveSheet(index) to make one of the target sheets active before grouping.","Verify the active sheet index with f.GetActiveSheetIndex() and adjust your sheet list accordingly."],"exampleFix":"// before\nf.SetActiveSheet(2)\nf.GroupSheets([]string{\"Sheet1\", \"Sheet2\"}) // active sheet missing\n// after\nf.SetActiveSheet(0) // make Sheet1 active\nf.GroupSheets([]string{\"Sheet1\", \"Sheet2\"})","handlingStrategy":"validation","validationCode":"active := f.GetActiveSheetName()\nif !slices.Contains(sheetNames, active) {\n    return fmt.Errorf(\"active sheet %q must be included in group\", active)\n}\nerr := f.GroupSheets(sheetNames)","typeGuard":"func canGroupSheets(f *excelize.File, names []string) bool {\n    return slices.Contains(names, f.GetActiveSheetName())\n}","tryCatchPattern":"if err := f.GroupSheets(names); errors.Is(err, excelize.ErrGroupSheets) {\n    // activate one of the target sheets and retry\n    _ = f.SetActiveSheet(indexOf(names[0]))\n    err = f.GroupSheets(names)\n}","preventionTips":["Always include f.GetActiveSheetName() in the grouping list.","Call SetActiveSheet on a target sheet right before grouping.","Re-check the active sheet after any code path that changes tabs."],"tags":["go","excelize","worksheet","grouping","validation"],"backgroundTag":"active-sheet-not-in-group","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}