{"record":{"id":"a50f3fe82587ae3f","repo":"iOfficeAI/OfficeCLI","slug":"column-span-cellref-covers-to-from-1-colum","errorCode":null,"errorMessage":"Column span {cellRef} covers {to - from + 1} columns (limit 1024). Narrow the span or address columns individually as col[X].","messagePattern":"Column span (.+?) covers (.+?) columns \\(limit 1024\\)\\. Narrow the span or address columns individually as col\\[X\\]\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Helpers.cs","lineNumber":39,"sourceCode":"    /// aliases for the canonical col[X]/row[N] path segments — same policy as\n    /// A1-style ranges (`A1:D10`), which the path grammar already accepts.\n    /// Returns the expanded canonical segments in axis order (one per\n    /// column/row in the span), or null when the segment is not an axis\n    /// reference. Canonical readback paths remain col[X]/row[N].\n    /// Spans wider than 1024 are rejected — a set over B:XFD (16k columns)\n    /// is almost certainly a mistake, not intent.\n    /// </summary>\n    private static List<string>? TryExpandAxisRef(string cellRef)\n    {\n        var colRef = System.Text.RegularExpressions.Regex.Match(\n            cellRef, @\"^([A-Za-z]{1,3}):([A-Za-z]{1,3})$\");\n        if (colRef.Success)\n        {\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        }","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Helpers.cs#L21-L57","documentation":"A path axis ref like A:ZZZ expands to more than 1024 columns. The library refuses to materialize such a huge span because it would blow up memory and produce a workbook that is slow or impossible to open. The cap is a deliberate resource guard, not an Excel limit (Excel allows the full 16384-column grid).","triggerScenarios":"Passing an axis ref matching ^([A-Za-z]{1,3}):([A-Za-z]{1,3})$ where the span (to - from + 1) exceeds 1024, e.g. 'A:ZZZ' (702 cols ok, but 'A:XFD' = 16384 trips), 'B:XFD'.","commonSituations":"Trying to apply formatting or values across a whole-grid column range; autogenerated style rules that target broad spans; misunderstanding the per-call budget.","solutions":["Narrow the span to <= 1024 columns per call.","Address columns individually as col[X] for scattered targets.","Apply column defaults at the sheet or workbook level rather than expanding a span."],"exampleFix":"// before\nsheet.ApplyToAxis(\"A:XFD\", ...);   // 16384 cols > 1024\n\n// after\nforeach (var colName in ChunkColumns(\"A\", \"XFD\", 1024))\n    sheet.ApplyToAxis($\"{colName.Start}:{colName.End}\", ...);","handlingStrategy":"validation","validationCode":"const int MaxAxisSpan = 1024;\nstatic bool ColumnSpanOk(string fromCol, string toCol) {\n    int a = ColumnNameToIndex(fromCol), b = ColumnNameToIndex(toCol);\n    return Math.Abs(b - a) + 1 <= MaxAxisSpan;\n}","typeGuard":null,"tryCatchPattern":"try { sheet.ApplyToAxis(span, ...); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"limit 1024\")) {\n    foreach (var chunk in ChunkSpan(span, 1024)) sheet.ApplyToAxis(chunk, ...);\n}","preventionTips":["Chunk broad column spans into <= 1024-wide calls.","Prefer sheet/column-level defaults over per-cell expansion for whole-grid styling."],"tags":["excel","columns","cli","limits"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}