{"record":{"id":"157fcbbab4c36b2f","repo":"iOfficeAI/OfficeCLI","slug":"sheet-not-found-sheetname-157fcb","errorCode":null,"errorMessage":"Sheet not found: {sheetName}","messagePattern":"Sheet not found: (.+?)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Query.Cf.cs","lineNumber":246,"sourceCode":"            if (rule.TimePeriod?.HasValue == true) cfNode.Format[\"period\"] = rule.TimePeriod.InnerText;\n            if (rule.FormatId?.Value != null) cfNode.Format[\"dxfId\"] = rule.FormatId.Value;\n        }\n\n        // Resolve dxfId to actual fill/font colors from the stylesheet\n        if (rule.FormatId?.Value != null)\n            PopulateCfNodeFromDxf(cfNode, (int)rule.FormatId.Value);\n    }\n\n    /// <summary>\n    /// One node per conditional-formatting RULE across all cf elements on a\n    /// sheet (a &lt;conditionalFormatting&gt; may hold several &lt;cfRule&gt;\n    /// children). The dump emitter iterates this so every rule round-trips;\n    /// counting cf ELEMENTS alone dropped the 2nd+ rule of a shared element.\n    /// </summary>\n    public List<DocumentNode> GetDumpCfRuleNodes(string sheetName)\n    {\n        var worksheet = FindWorksheet(sheetName)\n            ?? throw new System.ArgumentException($\"Sheet not found: {sheetName}\");\n        var result = new List<DocumentNode>();\n        foreach (var cf in GetSheet(worksheet).Elements<ConditionalFormatting>())\n        {\n            var refStr = cf.SequenceOfReferences?.InnerText ?? \"\";\n            foreach (var rule in cf.Elements<ConditionalFormattingRule>())\n            {\n                var node = new DocumentNode { Type = \"conditionalFormatting\" };\n                node.Format[\"ref\"] = refStr;\n                PopulateCfNodeFromRule(worksheet, rule, node);\n                result.Add(node);\n            }\n        }\n        return result;\n    }\n}\n","sourceCodeStart":228,"sourceCodeEnd":262,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Query.Cf.cs#L228-L262","documentation":"Thrown by ExcelHandler.GetDumpCfRuleNodes when the supplied sheetName does not resolve to any worksheet via FindWorksheet. This dump entry point enumerates conditional-formatting rules per sheet, so it requires an existing sheet.","triggerScenarios":"Calling GetDumpCfRuleNodes with a typo'd, missing, or stale sheet name; calling it before any sheet exists in the workbook.","commonSituations":"A dump/export tool that iterates a stale list of sheet names; a renamed sheet referenced by its old label; an LLM hallucinating a sheet name.","solutions":["List sheets first via Get('/') and pass the exact name returned.","Create the sheet before dumping its conditional formats.","If iterating by index, resolve the name through the same Get('/') listing rather than guessing."],"exampleFix":"// before\nvar rules = excel.GetDumpCfRuleNodes(\"SheetX\");   // does not exist\n\n// after\nvar sheets = excel.Get(\"/\").Children.Select(c => c.Preview);\nvar name   = sheets.First(n => n.Equals(\"sheetx\", StringComparison.OrdinalIgnoreCase));\nvar rules  = excel.GetDumpCfRuleNodes(name);","handlingStrategy":"validation","validationCode":"if (excel.FindWorksheet(sheetName) == null)\n    throw new ArgumentException($\"Sheet '{sheetName}' does not exist.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Drive GetDumpCfRuleNodes from the live Get('/') sheet list rather than a cached name set.","Create the sheet before dumping its conditional formats.","Resolve names case-insensitively against the current sheet list."],"tags":["excel","conditional-formatting","validation","sheet-not-found"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}