{"record":{"id":"f03fcd6a70de201c","repo":"qax-os/excelize","slug":"row-number-exceeds-maximum-limit","errorCode":null,"errorMessage":"row number exceeds maximum limit","messagePattern":"row number exceeds maximum limit","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":102,"sourceCode":"\t// value exceeds limit.\n\tErrFormControlValue = fmt.Errorf(\"scroll value must be an integer from 0 to %d\", MaxFormControlValue)\n\t// ErrGroupSheets defined the error message on group sheets.\n\tErrGroupSheets = errors.New(\"group worksheet must contain an active worksheet\")\n\t// ErrImgExt defined the error message on receive an unsupported image\n\t// extension.\n\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\")","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L84-L120","documentation":"ErrMaxRows is returned when an operation would produce a row number beyond the maximum supported row limit (1,048,576 rows for xlsx). It guards row-dimension adjustments and formula row-number adjustments from overflowing the format's limits.","triggerScenarios":"Calling adjust APIs (e.g. duplicate/insert row operations in adjustRowDimensions) with an offset that pushes the last row past TotalRows, or a formula like \"=A1048576\" being shifted down by adjustFormulaRowNumber.","commonSituations":"Programmatically inserting or duplicating many rows near the bottom of a full sheet, auto-filling formulas that reference the last valid row, or generated reports exceeding the xlsx row cap.","solutions":["Reduce the insert/offset amount so the resulting last row stays at or below 1,048,576.","Check the last row plus offset against the TotalRows limit before performing the adjustment.","Split data across multiple sheets when the row count approaches the maximum.","For formula adjustments, clamp or rewrite references so shifted row numbers stay within range."],"exampleFix":"// before\noffset := 1000 // last row is 1048570, would exceed limit\n// after\nif lastRow+offset > 1048576 { offset = 1048576 - lastRow }","handlingStrategy":"validation","validationCode":"const maxRows = 1048576\nif lastRow+offset > maxRows {\n    return fmt.Errorf(\"operation would exceed max row limit: %d > %d\", lastRow+offset, maxRows)\n}","typeGuard":null,"tryCatchPattern":"if err := adjustRows(f, sheet, row, offset); errors.Is(err, excelize.ErrMaxRows) {\n    // reduce the offset to fit or split across sheets\n    offset = maxRows - lastRow\n    err = adjustRows(f, sheet, row, offset)\n}","preventionTips":["Always compute lastRow + offset against the 1,048,576 limit before insert/duplicate operations.","Split very large datasets across multiple sheets.","Clamp formula references to the maximum row before shifting.","Keep a safety margin below the hard limit in generated reports."],"tags":["go","excelize","rows","limit-exceeded","validation"],"backgroundTag":"row-limit-exceeded","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}