{"record":{"id":"33ce015aa981255a","repo":"iOfficeAI/OfficeCLI","slug":"sheet-not-found-cbsheetname","errorCode":null,"errorMessage":"Sheet not found: {cbSheetName}","messagePattern":"Sheet not found: (.+?)","errorType":"validation","errorClass":"System.ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Add.Cells.cs","lineNumber":1370,"sourceCode":"        if (properties.TryGetValue(\"manual\", out var rbMan))\n            rbBreak.ManualPageBreak = IsTruthy(rbMan);\n        rowBreaks.AppendChild(rbBreak);\n        rowBreaks.Count = (uint)rowBreaks.Elements<Break>().Count();\n        rowBreaks.ManualBreakCount = rowBreaks.Count;\n        SaveWorksheet(rbWorksheet);\n\n        var rbIdx = rowBreaks.Elements<Break>().ToList()\n            .FindIndex(b => b.Id?.Value == rbRowIdx) + 1;\n        return $\"/{rbSheetName}/rowbreak[{rbIdx}]\";\n    }\n\n    private string AddColBreak(string parentPath, string type, InsertPosition? position, Dictionary<string, string> properties)\n    {\n        var index = position?.Index;\n        var cbSegments = parentPath.TrimStart('/').Split('/', 2);\n        var cbSheetName = cbSegments[0];\n        var cbWorksheet = FindWorksheet(cbSheetName)\n            ?? throw new ArgumentException($\"Sheet not found: {cbSheetName}\");\n        var cbWs = GetSheet(cbWorksheet);\n\n        var cbColStr = properties.GetValueOrDefault(\"col\") ?? properties.GetValueOrDefault(\"column\")\n            ?? properties.GetValueOrDefault(\"index\")\n            ?? throw new ArgumentException(\"'col' property is required for colbreak\");\n        // Accept both numeric index (e.g. \"3\") and column letter (e.g. \"C\")\n        var cbColIdx = uint.TryParse(cbColStr, out var cbNumVal)\n            ? cbNumVal\n            : (uint)ColumnNameToIndex(cbColStr.ToUpperInvariant());\n        // Same schema Min/Max guard as rowbreak: 0 / beyond-XFD ids write\n        // invalid OOXML that only surfaces at validate/open time.\n        if (cbColIdx < 1 || cbColIdx > 16384)\n            throw new ArgumentException(\n                $\"Invalid 'col' value: '{cbColStr}'. Column breaks must be between 1 and 16384 (A-XFD).\");\n\n        var colBreaks = cbWs.GetFirstChild<ColumnBreaks>();\n        if (colBreaks == null)\n        {","sourceCodeStart":1352,"sourceCodeEnd":1388,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Add.Cells.cs#L1352-L1388","documentation":"Thrown by AddColBreak when FindWorksheet(cbSheetName) returns null. The sheet name is the first segment of parentPath after trimming the leading slash. There is no path-length precondition before this check, so an empty or single-segment path whose first segment is not a worksheet also lands here.","triggerScenarios":"Add type=colbreak with parentPath=\"/BadSheet\" or a path whose sheet segment does not match any worksheet. Routed here from the break dispatcher when col/column properties are present. A typo or stale sheet name triggers it.","commonSituations":"Sheet renamed or removed after the path was captured. Script reuses a sheet name constant from a different workbook. Leading/trailing whitespace in the sheet segment.","solutions":["Verify the sheet name with a Get on / and use it verbatim.","Create the sheet if it does not yet exist.","Ensure the path begins with /<exactSheetName>."],"exampleFix":"// before\nhandler.Add(\"/OldName\", \"colbreak\", null, new() { [\"col\"] = \"C\" });\n\n// after\nhandler.Add(\"/Sheet1\", \"colbreak\", null, new() { [\"col\"] = \"C\" });","handlingStrategy":"validation","validationCode":"string sheet = \"Sheet1\";\nvar sheets = handler.Query(\"/\");\nif (!sheets.Any(s => string.Equals(s.Name, sheet, StringComparison.OrdinalIgnoreCase)))\n    throw new InvalidOperationException($\"Sheet not found: {sheet}\");\nhandler.Add(\"/\" + sheet, \"colbreak\", null, props);","typeGuard":"static bool SheetExists(IExcelHandler h, string sheet)\n    => h.Query(\"/\").Any(s => string.Equals(s.Name, sheet, StringComparison.OrdinalIgnoreCase));","tryCatchPattern":"try { handler.Add(parentPath, \"colbreak\", null, props); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Sheet not found\"))\n{ /* create the sheet or report the missing name */ }","preventionTips":["Resolve sheet names from a current sheet listing.","Create the sheet before adding column breaks.","Use a /{sheet} path helper to keep the segment well-formed."],"tags":["excel","ooxml","colbreak","sheet-not-found","argument"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}