{"record":{"id":"0cfebb8d8cf9a981","repo":"qax-os/excelize","slug":"errpivottableclassiclayout","errorCode":"ErrPivotTableClassicLayout","errorMessage":"cannot enable ClassicLayout and CompactData in the same time","messagePattern":"cannot enable ClassicLayout and CompactData in the same time","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":138,"sourceCode":"\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\n\t// name.\n\tErrSheetNameBlank = errors.New(\"the sheet name can not be blank\")\n\t// ErrSheetNameInvalid defined the error message on receive the sheet name\n\t// contains invalid characters.\n\tErrSheetNameInvalid = errors.New(\"the sheet can not contain any of the characters :\\\\/?*[or]\")\n\t// ErrSheetNameLength defined the error message on receiving the sheet\n\t// name length exceeds the limit.\n\tErrSheetNameLength = fmt.Errorf(\"the sheet name length exceeds the %d characters limit\", MaxSheetNameLength)\n\t// ErrSheetNameSingleQuote defined the error message on the first or last\n\t// character of the sheet name was a single quote.\n\tErrSheetNameSingleQuote = errors.New(\"the first or last character of the sheet name can not be a single quote\")\n\t// ErrSparkline defined the error message on receive the invalid sparkline","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L120-L156","documentation":"ErrPivotTableClassicLayout is returned when a pivot table's options enable both CompactData and ClassicLayout, which are mutually exclusive layout modes in Excel. parseFormatPivotTableSet rejects the combination before building the pivot table.","triggerScenarios":"f.AddPivotTable or f.SetPivotTable with a *PivotTableOptions where CompactData == true && ClassicLayout == true (pivotTable.go:359).","commonSituations":"Merging option sets from two configs where each enables one flag; toggling ClassicLayout without unsetting CompactData; copying example code for each flag independently.","solutions":["Set ClassicLayout: true and CompactData: false (or vice versa)","Before calling, zero out one flag when the other is enabled","Persist only one layout choice in your configuration"],"exampleFix":"// before\nopts := &excelize.PivotTableOptions{CompactData: true, ClassicLayout: true}\nf.AddPivotTable(opts)\n// after\nopts := &excelize.PivotTableOptions{CompactData: false, ClassicLayout: true}\nf.AddPivotTable(opts)","handlingStrategy":"validation","validationCode":"if opts.CompactData && opts.ClassicLayout {\n    opts.CompactData = false // enforce one layout mode\n}\nerr := f.AddPivotTable(opts)","typeGuard":"func layoutConflict(o excelize.PivotTableOptions) bool { return o.CompactData && o.ClassicLayout }","tryCatchPattern":"if err := f.AddPivotTable(opts); errors.Is(err, excelize.ErrPivotTableClassicLayout) { opts.ClassicLayout = false; err = f.AddPivotTable(opts) }","preventionTips":["Treat CompactData and ClassicLayout as a single layout enum in your code","Zero one flag when enabling the other","Centralize pivot option construction to avoid flag conflicts"],"tags":["go","excelize","pivot-table","conflicting-options"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}