{"record":{"id":"3af0a49865c2dcc2","repo":"iOfficeAI/OfficeCLI","slug":"picture-shape-name-column-row-index-must-be-in-3af0a4","errorCode":null,"errorMessage":"Picture/shape {name} column/row index must be in [0, {MaxCellIndex - 1}] (got '{value}'). For EMU-scale offsets use a unit-qualified value like '1in' / '6cm' / '72pt'.","messagePattern":"Picture/shape (.+?) column/row index must be in \\[0, (.+?)\\] \\(got '(.+?)'\\)\\. For EMU-scale offsets use a unit-qualified value like '1in' / '6cm' / '72pt'\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Helpers.Drawing.cs","lineNumber":1682,"sourceCode":"            if (plainInt < 0)\n                throw new ArgumentException($\"Picture/shape {name} must be non-negative (got '{value}').\");\n            // Excel's column max (16384) is the tightest sheet-coordinate\n            // bound — anything beyond that is unambiguously an EMU offset\n            // (rows go to 1048576 but a row index that high is also clearly\n            // EMU in practice). Use the same threshold for x and y so users\n            // passing inch-EMU (914400) consistently land on a sensible cell\n            // on either axis.\n            const int MaxCellIndex = 16384;\n            // R39-2: bare cell-count form must reject above-grid values\n            // outright. Previously, x=20000 hit the \"large bare int = EMU\"\n            // branch and divided by 609600, silently coercing the origin\n            // back to col=0 (or row=0 for y). Cell-count input is small\n            // by definition; if a user passes a number above the column\n            // max, it's either a typo or an EMU value mistakenly fed\n            // without a unit suffix. Either way, refuse rather than silently\n            // remap. CONSISTENCY with R30-1 negative guard.\n            if (plainInt > MaxCellIndex - 1)\n                throw new ArgumentException(\n                    $\"Picture/shape {name} column/row index must be in [0, {MaxCellIndex - 1}] (got '{value}'). For EMU-scale offsets use a unit-qualified value like '1in' / '6cm' / '72pt'.\");\n            return (int)plainInt;\n        }\n\n        // Unit-qualified (\"1in\", \"2cm\") → EMU → cell count via the same per-cell constants.\n        long emu;\n        try\n        {\n            emu = OfficeCli.Core.EmuConverter.ParseEmu(value);\n        }\n        catch\n        {\n            throw new ArgumentException($\"Expected an integer cell index or a unit-qualified offset (e.g. '1in', '2cm') for {name}, got '{value}'.\");\n        }\n        if (emu < 0)\n            throw new ArgumentException($\"Picture/shape {name} must be non-negative (got '{value}').\");\n        long perCellOut = (name == \"y\") ? EmuPerRowApprox : EmuPerColApprox;\n        return (int)(emu / perCellOut);","sourceCodeStart":1664,"sourceCodeEnd":1700,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Helpers.Drawing.cs#L1664-L1700","documentation":"Thrown by ParseAnchorOriginCell when a bare-integer x/y origin exceeds Excel's column max (16383, MaxCellIndex-1). R39-2 added this guard because previously x=20000 hit the 'large bare int = EMU' heuristic, divided by 609600, and silently coerced the origin back to col=0 (or row=0) - a silent data-corrupting remap. Users wanting EMU-scale offsets must use a unit-qualified form.","triggerScenarios":"Passing x=20000 or y=100000 as a bare integer (above 16383). The parser refuses to guess EMU-vs-cell-count and tells the user to add a unit suffix for EMU-scale offsets.","commonSituations":"Passing a raw EMU value (e.g. 914400 for 1 inch) without a suffix; confusing pixel/EMU magnitudes with cell counts; AI assistants emitting large dimensionless numbers for x/y.","solutions":["If you meant a cell index, keep it in [0, 16383]: x=5.","If you meant an EMU-scale offset, add a unit suffix: x='914400emu', x='1in', x='6cm', or x='72pt'.","Use anchor='B2' (cell reference) for positional anchoring instead of numeric x/y.","Verify whether your value is in cells, EMU, inches, or pixels before passing."],"exampleFix":"// before\nshape x=914400\n// after\nshape x=1in","handlingStrategy":"validation","validationCode":"const int MaxCellIndex = 16384;\nbool IsValidBareOriginCell(string value)\n    => long.TryParse(value, out var l) && l >= 0 && l <= MaxCellIndex - 1;\n\nbool IsEmuScaleOffset(string value)\n    => OfficeCli.Core.EmuConverter.TryParseEmu(value, out _)\n       && value.EndsWithAny(new[]{\"in\",\"cm\",\"mm\",\"pt\",\"pc\",\"px\",\"Q\",\"emu\"});","typeGuard":"static bool IsWithinGridCellOrigin(string s)\n    => long.TryParse(s, out var l) && l >= 0 && l <= 16383;","tryCatchPattern":"try { ParseAnchorOriginCell(value, \"x\"); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"column/row index must be in [0,\"))\n{\n    // add a unit suffix for EMU-scale offsets, or clamp to <= 16383 for cell indices\n}","preventionTips":["Keep bare-integer cell origins within [0, 16383].","Add a unit suffix ('1in','6cm','72pt','914400emu') for EMU-scale offsets.","Use anchor='B2' (cell reference) for positional anchoring.","Verify whether the value is in cells, EMU, inches, or pixels before passing."],"tags":["excel","drawing","anchor","origin","emu","validation","grid-limit"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}