{"record":{"id":"8629c83ee5e7e5d1","repo":"qax-os/excelize","slug":"the-name-length-exceeds-the-d-characters-limit","errorCode":null,"errorMessage":"the name length exceeds the %d characters limit","messagePattern":"the name length exceeds the (.+?) characters limit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":105,"sourceCode":"\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)\n\t// ErrMaxGraphicAltTextLength defined the error message on receiving the\n\t// graphic alt text length exceeds the limit.\n\tErrMaxGraphicAltTextLength = fmt.Errorf(\"the alt text length exceeds the %d characters limit\", MaxGraphicAltTextLength)\n\t// ErrMaxGraphicNameLength defined the error message on receiving the\n\t// graphic name length exceeds the limit.\n\tErrMaxGraphicNameLength = fmt.Errorf(\"the name length exceeds the %d characters limit\", MaxGraphicNameLength)\n\t// ErrOptionsUnzipSizeLimit defined the error message for receiving\n\t// invalid UnzipSizeLimit and UnzipXMLSizeLimit.\n\tErrOptionsUnzipSizeLimit = errors.New(\"the value of UnzipSizeLimit should be greater than or equal to UnzipXMLSizeLimit\")\n\t// ErrOutlineLevel defined the error message on receive an invalid outline\n\t// level number.\n\tErrOutlineLevel = errors.New(\"invalid outline level\")\n\t// ErrPageSetupAdjustTo defined the error message for receiving a page setup\n\t// adjust to value exceeds limit.\n\tErrPageSetupAdjustTo = errors.New(\"adjust to value must be an integer from 0 to 400\")\n\t// ErrParameterInvalid defined the error message on receive the invalid\n\t// parameter.\n\tErrParameterInvalid = errors.New(\"parameter is invalid\")","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L87-L123","documentation":"ErrNameLength is returned when a user-supplied name (defined name or pivot table name) exceeds MaxFieldLength (255) characters as counted in UTF-16 code units. parseFormatPivotTableSet validates the PivotTableOptions.Name before building the pivot table, and checkDefinedName validates defined names. Excel caps these identifiers, so excelize rejects longer ones up front.","triggerScenarios":"f.AddPivotTable(&excelize.PivotTableOptions{Name: strings.Repeat(\"x\", 256), ...}); defining a workbook/table name longer than 255 UTF-16 characters via the name-related APIs.","commonSituations":"Generating names programmatically from long strings (e.g. concatenating dataset IDs or timestamps into a pivot name); auto-derived names from file titles or query text.","solutions":["Shorten the name to <= 255 UTF-16 characters before calling the API","Generate a shorter deterministic name (e.g. truncate + hash suffix) when names are built from user data","Check length first with utf8.RuneCountInString/UTF-16-aware counting to fail early in your own code"],"exampleFix":"// before\nname := longDerivedName // may exceed 255\nerr := f.AddPivotTable(&excelize.PivotTableOptions{Name: name, ...})\n// after\nif len([]rune(name)) > 255 {\n\tname = name[:250] + \"_pt\"\n}\nerr := f.AddPivotTable(&excelize.PivotTableOptions{Name: name, ...})","handlingStrategy":"validation","validationCode":"if len([]rune(name)) > 255 { return fmt.Errorf(\"name too long\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Truncate programmatic names to 255 UTF-16 chars before AddPivotTable or defined-name APIs","Generate short machine names (prefix + hash) instead of long descriptive ones","Count UTF-16 code units, not bytes, for non-ASCII names"],"tags":["excelize","name-length","pivot-table","limits"],"backgroundTag":"name-too-long","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}