{"record":{"id":"2a5fc8cf32196b79","repo":"qax-os/excelize","slug":"data-validation-range-exceeds-limit","errorCode":null,"errorMessage":"data validation range exceeds limit","messagePattern":"data validation range exceeds limit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":52,"sourceCode":"\tErrChartTitle = errors.New(\"cannot set both 'Formula' and 'Paragraph' for chart title\")\n\t// ErrColumnNumber defined the error message on receive an invalid column\n\t// number.\n\tErrColumnNumber = fmt.Errorf(\"the column number must be greater than or equal to %d and less than or equal to %d\", MinColumns, MaxColumns)\n\t// ErrColumnWidth defined the error message on receive an invalid column\n\t// width.\n\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.","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L34-L70","documentation":"ErrDataValidationRange is returned by Excelize when a data validation formula value is a float64 whose absolute value exceeds math.MaxFloat32. Data validation ranges in Excel are constrained to 32-bit float precision, so out-of-range values like math.MaxFloat64 would be silently corrupted or rejected by Excel. The library throws it from SetRange (datavalidation.go:174) to surface this early instead of writing an invalid XLSX.","triggerScenarios":"Calling DataValidation.SetRange with a DataValidationTypeDecimal or DataValidationTypeWhole range whose float64 min or max has absolute value > math.MaxFloat32, e.g. SetRange(-math.MaxFloat64, math.MaxFloat32, DataValidationTypeWhole, DataValidationOperatorGreaterThan) or passing math.MaxFloat64 / math.SmallestNonzeroFloat64 extremes as bounds.","commonSituations":"Developers compute validation bounds from untyped config values or database numerics that are 64-bit floats; using Go's math.MaxFloat64/SmallestNonzeroFloat64 as 'no limit' sentinels when Excel's effective range is only ±3.4e38 (and integers up to ~2.1e9 for whole-number validations).","solutions":["Clamp the validation bounds to math.MaxFloat32 (or smaller, e.g. whole-number limit 2147483647) before calling SetRange.","Use operator-based validations (GreaterThanOrEqual with a sentinel like 0) instead of extreme min/max bounds to express 'unbounded'.","Convert 64-bit inputs from config/DB to float32 first and handle overflow at your application's boundary."],"exampleFix":"// before\ndv.SetRange(-math.MaxFloat64, math.MaxFloat64, DataValidationTypeDecimal, DataValidationOperatorBetween)\n// after\nlimit := float64(math.MaxFloat32)\ndv.SetRange(-limit, limit, DataValidationTypeDecimal, DataValidationOperatorBetween)","handlingStrategy":"validation","validationCode":"func inRange(v float64) bool { return !math.IsInf(v, 0) && !math.IsNaN(v) && math.Abs(v) <= math.MaxFloat32 }\n// before calling: if !inRange(min) || !inRange(max) { clamp or skip SetRange }","typeGuard":"func safeValidationBound(v float64) (float64, bool) {\n\tif math.Abs(v) > math.MaxFloat32 {\n\t\treturn 0, false\n\t}\n\treturn v, true\n}","tryCatchPattern":"err := dv.SetRange(min, max, excelize.DataValidationTypeDecimal, excelize.DataValidationOperatorBetween)\nif errors.Is(err, excelize.ErrDataValidationRange) {\n\t// clamp bounds to math.MaxFloat32 and retry\n}","preventionTips":["Clamp all user/config numeric inputs to math.MaxFloat32 before using as validation bounds","Never use math.MaxFloat64 or math.SmallestNonzeroFloat64 as sentinel bounds for Excel validations","Remember whole-number validations should stay within ±2147483647"],"tags":["excelize","data-validation","float-overflow"],"backgroundTag":"numeric-range-overflow","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}