{"record":{"id":"386ff4f87f78d2af","repo":"qax-os/excelize","slug":"errparameterrequired","errorCode":"ErrParameterRequired","errorMessage":"parameter is required","messagePattern":"parameter is required","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":126,"sourceCode":"\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\")\n\t// ErrSave defined the error message for saving file.\n\tErrSave = errors.New(\"no path defined for file, consider File.WriteTo or File.Write\")\n\t// ErrSheetIdx defined the error message on receive the invalid worksheet\n\t// index.\n\tErrSheetIdx = errors.New(\"invalid worksheet index\")\n\t// ErrSheetNameBlank defined the error message on receive the blank sheet","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L108-L144","documentation":"ErrParameterRequired is returned when a required option struct or string is empty/nil. parseFormatPivotTableSet returns it if a nil *PivotTableOptions is passed, and adjustRange returns it if the range string is empty.","triggerScenarios":"f.AddPivotTable(nil) or f.AddPivotTable(&PivotTableOptions{...}) where PivotTableRange is \"\"; passing an empty sparkline format or an empty range string into any API that adjusts ranges.","commonSituations":"Options structs built conditionally and left nil; range strings assembled from config values that default to empty string; zero-value structs used accidentally.","solutions":["Check for nil before calling and construct a valid options struct","Ensure the range field is a non-empty string like \"Sheet1!A1:E31\"","Guard your code: return your own validation error before invoking the library"],"exampleFix":"// before\nvar opts *PivotTableOptions\nf.AddPivotTable(opts) // ErrParameterRequired\n// after\nopts := &excelize.PivotTableOptions{DataRange: \"Sheet1!A1:E31\", PivotTableRange: \"Sheet1!G2:M34\"}\nif err := f.AddPivotTable(opts); err != nil { return err }","handlingStrategy":"validation","validationCode":"if opts == nil || strings.TrimSpace(opts.PivotTableRange) == \"\" {\n    return errors.New(\"pivot table options and range are required\")\n}\nerr := f.AddPivotTable(opts)","typeGuard":"func optsProvided[T any](o *T) bool { return o != nil }","tryCatchPattern":"if err := f.AddPivotTable(opts); errors.Is(err, excelize.ErrParameterRequired) { // build defaults and retry }","preventionTips":["Never pass nil options structs to excelize APIs","Ensure range strings are non-empty and fully qualified (Sheet!Range)","Construct options with explicit field values instead of zero-value structs"],"tags":["go","excelize","missing-parameter","pivot-table"],"backgroundTag":"missing-required-argument","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}