{"record":{"id":"122a6a1bf1e3a108","repo":"qax-os/excelize","slug":"the-alt-text-length-exceeds-the-d-characters-limi","errorCode":null,"errorMessage":"the alt text length exceeds the %d characters limit","messagePattern":"the alt text length exceeds the (.+?) characters limit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":108,"sourceCode":"\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\")\n\t// ErrParameterRequired defined the error message on receive the empty\n\t// parameter.\n\tErrParameterRequired = errors.New(\"parameter is required\")","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L90-L126","documentation":"ErrMaxGraphicAltTextLength is returned by parseGraphicOptions when the GraphicOptions/PictureOptions AltText exceeds MaxGraphicAltTextLength characters (UTF-16 count). Alt text is stored in the drawing XML as accessible description and Excel enforces a length limit, so excelize validates before writing.","triggerScenarios":"f.AddPicture(\"Sheet1\", \"Q25\", \"img.svg\", &excelize.GraphicOptions{AltText: <string longer than MaxGraphicAltTextLength>}) or any API that routes options through parseGraphicOptions.","commonSituations":"Auto-filling alt text from long image captions, product descriptions, or URL strings; bulk-importing accessibility metadata from a CMS without truncation.","solutions":["Truncate AltText to MaxGraphicAltTextLength before calling AddPicture","Sanitize/shorten captions at the source (CMS or template) rather than at the call site","Validate with a UTF-16-aware length check and surface a friendly message to the user"],"exampleFix":"// before\nopts := &excelize.GraphicOptions{AltText: longCaption}\nerr := f.AddPicture(\"Sheet1\", \"Q25\", \"img.png\", opts)\n// after\nif len([]rune(longCaption)) > excelize.MaxGraphicAltTextLength {\n\tlongCaption = longCaption[:excelize.MaxGraphicAltTextLength]\n}\nerr := f.AddPicture(\"Sheet1\", \"Q25\", \"img.png\", &excelize.GraphicOptions{AltText: longCaption})","handlingStrategy":"validation","validationCode":"if len([]rune(altText)) > excelize.MaxGraphicAltTextLength { altText = altText[:excelize.MaxGraphicAltTextLength] }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Truncate captions/alt text at the source (CMS, template) before AddPicture","Keep a shared sanitizeGraphicOptions helper for all drawing calls","Watch UTF-16 length for CJK/emoji content"],"tags":["excelize","alt-text","accessibility","length-limit"],"backgroundTag":"name-too-long","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}