{"record":{"id":"ede514ebd687bd88","repo":"qax-os/excelize","slug":"errpagesetupadjustto","errorCode":"ErrPageSetupAdjustTo","errorMessage":"adjust to value must be an integer from 0 to 400","messagePattern":"adjust to value must be an integer from 0 to 400","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":120,"sourceCode":"\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\")\n\t// ErrPasswordLengthInvalid defined the error message on invalid password\n\t// length.\n\tErrPasswordLengthInvalid = errors.New(\"password length invalid\")\n\t// ErrPivotTableShowValuesAsBaseField defined the error message on enable\n\t// this kind of \"show values as\" type requires a base field.\n\tErrPivotTableShowValuesAsBaseField = errors.New(\"this kind of show values as type requires a base field\")\n\t// ErrPivotTableShowValuesAsBaseItem defined the error message on enable\n\t// this kind of \"show values as\" type and base field requires a base item.\n\tErrPivotTableShowValuesAsBaseItem = errors.New(\"this kind of show values as type and base field requires a base item\")\n\t// ErrPivotTableClassicLayout defined the error message on enable\n\t// ClassicLayout and CompactData in the same time.\n\tErrPivotTableClassicLayout = errors.New(\"cannot enable ClassicLayout and CompactData in the same time\")","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L102-L138","documentation":"ErrPageSetupAdjustTo is returned by SetPageLayout when the AdjustTo option is outside the range Excel allows (10 to 400 percent of normal size). The declared message mentions 0-400, but sheet.go:1689 enforces 10 <= v <= 400.","triggerScenarios":"Calling File.SetPageLayout(sheet, &PageLayoutOptions{AdjustTo: uintPtr(v)}) with v < 10 or v > 400, e.g. uintPtr(5) as in sheet_test.go:224.","commonSituations":"Hard-coding a scale value like 5 or 500 for a custom zoom; computing percentage from user input without bounds; confusing AdjustTo with a boolean fit-to-page flag.","solutions":["Set AdjustTo to an integer between 10 and 400","Omit AdjustTo (leave nil) if you do not need a custom scale","Clamp user-supplied scaling percentages before assigning"],"exampleFix":"// before\nf.SetPageLayout(\"Sheet1\", &PageLayoutOptions{AdjustTo: uintPtr(5)})\n// after\nf.SetPageLayout(\"Sheet1\", &PageLayoutOptions{AdjustTo: uintPtr(100)})","handlingStrategy":"validation","validationCode":"func validAdjustTo(v uint) bool { return v >= 10 && v <= 400 }\nif opts.AdjustTo != nil && validAdjustTo(*opts.AdjustTo) { err := f.SetPageLayout(sheet, opts) }","typeGuard":"func validAdjustTo(v uint) bool { return v >= 10 && v <= 400 }","tryCatchPattern":"if err := f.SetPageLayout(sheet, opts); errors.Is(err, excelize.ErrPageSetupAdjustTo) { // clamp and retry with 100 }","preventionTips":["Only set AdjustTo for genuine scale values (10-400%)","Leave AdjustTo nil unless a custom scale is needed","Clamp user-provided percentages before assigning"],"tags":["go","excelize","page-setup","parameter-validation"],"backgroundTag":"value-out-of-range","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}