iOfficeAI/OfficeCLI · error · System.ArgumentException
Sheet not found: {cisSheetName}
Error message
Sheet not found: {cisSheetName} What it means
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.
Source
Thrown at src/officecli/Handlers/Excel/ExcelHandler.Add.Cf.cs:520
};
var fcfWsElement = GetSheet(fcfWorksheet);
InsertConditionalFormatting(fcfWsElement, fcfCf);
SaveWorksheet(fcfWorksheet);
var fcfCfCount = fcfWsElement.Elements<ConditionalFormatting>().Count();
return $"/{fcfSheetName}/cf[{fcfCfCount}]";
}
private string AddCellIs(string parentPath, string type, InsertPosition? position, Dictionary<string, string> properties)
{
var index = position?.Index;
// R2-2: cellIs conditional formatting — compare each cell value against
// a literal (or formula) using one of greaterThan/lessThan/... operators.
var cisSegments = parentPath.TrimStart('/').Split('/', 2);
var cisSheetName = cisSegments[0];
var cisWorksheet = FindWorksheet(cisSheetName)
?? throw new ArgumentException($"Sheet not found: {cisSheetName}");
// CONSISTENCY(cf-sqref): three-level fallback matches dataBar/colorScale branches.
// R22-2: path-tail range is the fallback before the hardcoded default.
var cisPathRange = cisSegments.Length > 1 && !string.IsNullOrEmpty(cisSegments[1]) ? cisSegments[1] : "A1:A10";
var cisSqref = ValidateSqref(properties.GetValueOrDefault("sqref")
?? properties.GetValueOrDefault("range")
?? properties.GetValueOrDefault("ref", cisPathRange), "ref");
var opStr = (properties.GetValueOrDefault("operator") ?? "greaterThan").Trim();
var opVal = opStr.ToLowerInvariant() switch
{
"greaterthan" or "gt" or ">" => ConditionalFormattingOperatorValues.GreaterThan,
"lessthan" or "lt" or "<" => ConditionalFormattingOperatorValues.LessThan,
"greaterthanorequal" or "gte" or ">=" => ConditionalFormattingOperatorValues.GreaterThanOrEqual,
"lessthanorequal" or "lte" or "<=" => ConditionalFormattingOperatorValues.LessThanOrEqual,
"equal" or "eq" or "=" or "==" => ConditionalFormattingOperatorValues.Equal,
"notequal" or "ne" or "!=" or "<>" => ConditionalFormattingOperatorValues.NotEqual,
"between" => ConditionalFormattingOperatorValues.Between,
"notbetween" => ConditionalFormattingOperatorValues.NotBetween,View on GitHub (pinned to 1ced45e900)
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.
Example fix
// before: 'Sales' sheet missing add /Sales/A1:A10 cellis operator=greaterThan value=100 // after add-sheet Sales add /Sales/A1:A10 cellis operator=greaterThan value=100
Defensive patterns
Strategy: validation
Validate before calling
var sheet = parentPath.TrimStart('/').Split('/', 2)[0];
if (FindWorksheet(sheet) is null)
throw new ArgumentException($"Sheet '{sheet}' not found."); Type guard
static bool SheetExists(string? sheetName, IEnumerable<string> known)
=> sheetName is not null && known.Contains(sheetName, StringComparer.OrdinalIgnoreCase); Try / catch
try { return Add(path, "cellis", pos, props); }
catch (ArgumentException ex) when (ex.Message.StartsWith("Sheet not found"))
{ /* correct sheet name, retry */ throw; } Prevention
- Resolve the sheet name before building the cellIs path.
- Create the sheet if it does not exist.
- List sheets to verify current names.
When it happens
Trigger: 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.
Common situations: Stale or renamed sheet; typo; dynamically-built path with an unvalidated sheet token; using 'highlight' type alias without confirming the target sheet.
Related errors
- Sheet not found: {csSheetName}
- Sheet not found: {isSheetName}
- Sheet not found: {fcfSheetName}
- Sheet not found: {cfNewSheetName}
- Unsupported cellIs operator '{opStr}'. Valid: greaterThan, l
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/ac0e423d45e3f76d.
Report an issue: GitHub.