{"record":{"id":"eba42d22037e8808","repo":"iOfficeAI/OfficeCLI","slug":"row-span-cellref-covers-r2-r1-1-rows-limi","errorCode":null,"errorMessage":"Row span {cellRef} covers {r2 - r1 + 1} rows (limit 1024). Narrow the span or address rows individually as row[N].","messagePattern":"Row span (.+?) covers (.+?) rows \\(limit 1024\\)\\. Narrow the span or address rows individually as row\\[N\\]\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Helpers.cs","lineNumber":52,"sourceCode":"        {\n            var from = ColumnNameToIndex(colRef.Groups[1].Value.ToUpperInvariant());\n            var to = ColumnNameToIndex(colRef.Groups[2].Value.ToUpperInvariant());\n            if (from > to) (from, to) = (to, from);\n            if (to - from + 1 > 1024)\n                throw new ArgumentException(\n                    $\"Column span {cellRef} covers {to - from + 1} columns (limit 1024). Narrow the span or address columns individually as col[X].\");\n            var cols = new List<string>();\n            for (var i = from; i <= to; i++) cols.Add($\"col[{IndexToColumnName(i)}]\");\n            return cols;\n        }\n        var rowRef = System.Text.RegularExpressions.Regex.Match(cellRef, @\"^(\\d+):(\\d+)$\");\n        if (rowRef.Success\n            && uint.TryParse(rowRef.Groups[1].Value, out var r1) && r1 >= 1\n            && uint.TryParse(rowRef.Groups[2].Value, out var r2) && r2 >= 1)\n        {\n            if (r1 > r2) (r1, r2) = (r2, r1);\n            if (r2 - r1 + 1 > 1024)\n                throw new ArgumentException(\n                    $\"Row span {cellRef} covers {r2 - r1 + 1} rows (limit 1024). Narrow the span or address rows individually as row[N].\");\n            var rows = new List<string>();\n            for (var i = r1; i <= r2; i++) rows.Add($\"row[{i}]\");\n            return rows;\n        }\n        return null;\n    }\n\n    /// <summary>\n    /// Parse a print-margin value into inches (PageMargins schema unit).\n    /// Accepts \"1in\", \"2.5cm\", \"1.27cm\", \"72pt\", \"10mm\", or a bare number (inches).\n    /// </summary>\n    internal static double ParseMarginInches(string value)\n    {\n        if (string.IsNullOrWhiteSpace(value))\n            throw new ArgumentException(\"Invalid margin: empty value.\");\n        var v = value.Trim().ToLowerInvariant();\n        double num;","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Helpers.cs#L34-L70","documentation":"A path axis ref like 1:5000 expands to more than 1024 rows. As with the column case, the library refuses to materialize the span to avoid resource blowup. The 1024 cap is a per-call guard, not the Excel row limit (1048576).","triggerScenarios":"Passing an axis ref matching ^(\\d+):(\\d+)$ where both endpoints are >= 1 and (r2 - r1 + 1) > 1024, e.g. '1:5000', '100:2000'.","commonSituations":"Applying row formatting or values across a large dataset in one call; auto-generated rules targeting broad row ranges; misjudging the per-call budget.","solutions":["Narrow the span to <= 1024 rows per call.","Address rows individually as row[N] for scattered targets.","Use sheet-level row defaults or styles instead of expanding a span."],"exampleFix":"// before\nsheet.ApplyToAxis(\"1:5000\", ...);   // 5000 rows > 1024\n\n// after\nfor (var start = 1; start <= 5000; start += 1024) {\n    var end = Math.Min(start + 1023, 5000);\n    sheet.ApplyToAxis($\"{start}:{end}\", ...);\n}","handlingStrategy":"validation","validationCode":"const int MaxAxisSpan = 1024;\nstatic bool RowSpanOk(uint r1, uint r2) =>\n    Math.Abs((long)r2 - r1) + 1 <= MaxAxisSpan;","typeGuard":null,"tryCatchPattern":"try { sheet.ApplyToAxis(span, ...); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"limit 1024\")) {\n    foreach (var chunk in ChunkRowSpan(span, 1024)) sheet.ApplyToAxis(chunk, ...);\n}","preventionTips":["Chunk broad row spans into <= 1024-tall calls.","For large datasets, drive writes from the data iterator, not from axis spans."],"tags":["excel","rows","cli","limits"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}