{"record":{"id":"2277761c8973f2e9","repo":"qax-os/excelize","slug":"no-defined-name-on-the-scope","errorCode":null,"errorMessage":"no defined name on the scope","messagePattern":"no defined name on the scope","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"errors.go","lineNumber":58,"sourceCode":"\tErrColumnWidth = fmt.Errorf(\"the width of the column must be less than or equal to %d characters\", MaxColumnWidth)\n\t// ErrCoordinates defined the error message on invalid coordinates tuples\n\t// length.\n\tErrCoordinates = errors.New(\"coordinates length must be 4\")\n\t// ErrCustomNumFmt defined the error message on receive the empty custom\n\t// number format.\n\tErrCustomNumFmt = errors.New(\"custom number format can not be empty\")\n\t// ErrDataValidationFormulaLength defined the error message for receiving a\n\t// data validation formula length that exceeds the limit.\n\tErrDataValidationFormulaLength = fmt.Errorf(\"data validation must be 0-%d characters\", MaxFieldLength)\n\t// ErrDataValidationRange defined the error message on set decimal range\n\t// exceeds limit.\n\tErrDataValidationRange = errors.New(\"data validation range exceeds limit\")\n\t// ErrDefinedNameDuplicate defined the error message on the same name\n\t// already exists on the scope.\n\tErrDefinedNameDuplicate = errors.New(\"the same name already exists on the scope\")\n\t// ErrDefinedNameScope defined the error message on not found defined name\n\t// in the given scope.\n\tErrDefinedNameScope = errors.New(\"no defined name on the scope\")\n\t// ErrExistsSheet defined the error message on given sheet already exists.\n\tErrExistsSheet = errors.New(\"the same name sheet already exists\")\n\t// ErrExistsTableName defined the error message on given table already\n\t// exists.\n\tErrExistsTableName = errors.New(\"the same name table already exists\")\n\t// ErrFillType defined the error message on receive an invalid fill type.\n\tErrFillType = errors.New(\"fill type value must be one of 'gradient' or 'pattern'\")\n\t// ErrFillGradientColor defined the error message on receive an invalid fill\n\t// color for 'gradient' type.\n\tErrFillGradientColor = errors.New(\"fill color value must be an array of two colors for 'gradient' type\")\n\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.","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L40-L76","documentation":"ErrDefinedNameScope is returned when a defined name cannot be found on the given scope, most notably from DeleteDefinedName (sheet.go:1861). Excelize looks up the defined name by Name (and Scope); if no match exists it returns this error instead of failing silently.","triggerScenarios":"Calling f.DeleteDefinedName(&DefinedName{Name: \"No Exist Defined Name\"}) for a name that was never created or was created on a different scope/sheet than the one specified.","commonSituations":"Cleanup code deleting names that may not exist yet; scope mismatch (name defined workbook-wide but deleted with a sheet scope, or vice versa); typos in the name string.","solutions":["Only call DeleteDefinedName for names you know exist, or check the error and ignore this sentinel when deletion is best-effort.","Pass the same Scope value (0 for workbook scope, sheet index otherwise) used when the name was created.","Verify the exact name string matches, including case and spaces."],"exampleFix":"// before\nerr := f.DeleteDefinedName(&DefinedName{Name: \"No Exist Defined Name\"})\n// after\nerr := f.DeleteDefinedName(&DefinedName{Name: \"MyName\", Scope: 0})\nif err != nil && err != excelize.ErrDefinedNameScope {\n    return err\n}","handlingStrategy":"try-catch","validationCode":"// Keep a set of defined names you created:\nif !createdNames[name] { skip deletion }","typeGuard":"func definedNameExists(f *excelize.File, name string) bool {\n\treturn f.DeleteDefinedName(&excelize.DefinedName{Name: name}) != excelize.ErrDefinedNameScope\n}","tryCatchPattern":"err := f.DeleteDefinedName(&excelize.DefinedName{Name: name})\nif errors.Is(err, excelize.ErrDefinedNameScope) {\n\treturn nil // nothing to delete; not an error for best-effort cleanup\n}","preventionTips":["Treat ErrDefinedNameScope as success in idempotent cleanup code","Pass the exact Scope (0 = workbook) the name was created with","Define name strings as constants to avoid typos"],"tags":["excelize","defined-names","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}