{"record":{"id":"ac0e423d45e3f76d","repo":"iOfficeAI/OfficeCLI","slug":"sheet-not-found-cissheetname","errorCode":null,"errorMessage":"Sheet not found: {cisSheetName}","messagePattern":"Sheet not found: (.+?)","errorType":"validation","errorClass":"System.ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Add.Cf.cs","lineNumber":520,"sourceCode":"        };\n\n        var fcfWsElement = GetSheet(fcfWorksheet);\n        InsertConditionalFormatting(fcfWsElement, fcfCf);\n\n        SaveWorksheet(fcfWorksheet);\n        var fcfCfCount = fcfWsElement.Elements<ConditionalFormatting>().Count();\n        return $\"/{fcfSheetName}/cf[{fcfCfCount}]\";\n    }\n\n    private string AddCellIs(string parentPath, string type, InsertPosition? position, Dictionary<string, string> properties)\n    {\n        var index = position?.Index;\n        // R2-2: cellIs conditional formatting — compare each cell value against\n        // a literal (or formula) using one of greaterThan/lessThan/... operators.\n        var cisSegments = parentPath.TrimStart('/').Split('/', 2);\n        var cisSheetName = cisSegments[0];\n        var cisWorksheet = FindWorksheet(cisSheetName)\n            ?? throw new ArgumentException($\"Sheet not found: {cisSheetName}\");\n\n        // CONSISTENCY(cf-sqref): three-level fallback matches dataBar/colorScale branches.\n        // R22-2: path-tail range is the fallback before the hardcoded default.\n        var cisPathRange = cisSegments.Length > 1 && !string.IsNullOrEmpty(cisSegments[1]) ? cisSegments[1] : \"A1:A10\";\n        var cisSqref = ValidateSqref(properties.GetValueOrDefault(\"sqref\")\n            ?? properties.GetValueOrDefault(\"range\")\n            ?? properties.GetValueOrDefault(\"ref\", cisPathRange), \"ref\");\n        var opStr = (properties.GetValueOrDefault(\"operator\") ?? \"greaterThan\").Trim();\n        var opVal = opStr.ToLowerInvariant() switch\n        {\n            \"greaterthan\" or \"gt\" or \">\" => ConditionalFormattingOperatorValues.GreaterThan,\n            \"lessthan\" or \"lt\" or \"<\" => ConditionalFormattingOperatorValues.LessThan,\n            \"greaterthanorequal\" or \"gte\" or \">=\" => ConditionalFormattingOperatorValues.GreaterThanOrEqual,\n            \"lessthanorequal\" or \"lte\" or \"<=\" => ConditionalFormattingOperatorValues.LessThanOrEqual,\n            \"equal\" or \"eq\" or \"=\" or \"==\" => ConditionalFormattingOperatorValues.Equal,\n            \"notequal\" or \"ne\" or \"!=\" or \"<>\" => ConditionalFormattingOperatorValues.NotEqual,\n            \"between\" => ConditionalFormattingOperatorValues.Between,\n            \"notbetween\" => ConditionalFormattingOperatorValues.NotBetween,","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Add.Cf.cs#L502-L538","documentation":"Thrown by AddCellIs when the first segment of parentPath does not resolve to a worksheet. The cellIs rule (greaterThan/lessThan/between/etc.) must attach to a worksheet element and compute priority against existing rules on that sheet.","triggerScenarios":"Calling Add with parentPath '/<sheet>/...' and type=cellis (or cf type=cellis, or cf type=highlight with an operator=) where <sheet> is not a worksheet in the workbook.","commonSituations":"Stale or renamed sheet; typo; dynamically-built path with an unvalidated sheet token; using 'highlight' type alias without confirming the target sheet.","solutions":["Use the exact worksheet name as segment[0] of the path.","Create the worksheet first if it does not exist.","List current sheet names and re-run with the correct one."],"exampleFix":"// before: 'Sales' sheet missing\nadd /Sales/A1:A10 cellis operator=greaterThan value=100\n// after\nadd-sheet Sales\nadd /Sales/A1:A10 cellis operator=greaterThan value=100","handlingStrategy":"validation","validationCode":"var sheet = parentPath.TrimStart('/').Split('/', 2)[0];\nif (FindWorksheet(sheet) is null)\n    throw new ArgumentException($\"Sheet '{sheet}' not found.\");","typeGuard":"static bool SheetExists(string? sheetName, IEnumerable<string> known)\n    => sheetName is not null && known.Contains(sheetName, StringComparer.OrdinalIgnoreCase);","tryCatchPattern":"try { return Add(path, \"cellis\", pos, props); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Sheet not found\"))\n{ /* correct sheet name, retry */ throw; }","preventionTips":["Resolve the sheet name before building the cellIs path.","Create the sheet if it does not exist.","List sheets to verify current names."],"tags":["excel","conditional-formatting","cellis","sheet-resolution","path-validation"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}