{"record":{"id":"00113a14950b750c","repo":"iOfficeAI/OfficeCLI","slug":"sheet-not-found-picsheetname","errorCode":null,"errorMessage":"Sheet not found: {picSheetName}","messagePattern":"Sheet not found: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Add.Drawings.cs","lineNumber":270,"sourceCode":"                oleWsElement.InsertBefore(oleObjects, insertBefore);\n            else\n                oleWsElement.AppendChild(oleObjects);\n        }\n        oleObjects.AppendChild(oleObj);\n\n        SaveWorksheet(oleWorksheet);\n\n        var oleCount = oleWsElement.Descendants<OleObject>().Count();\n        return $\"/{oleSheetName}/ole[{oleCount}]\";\n    }\n\n    private string AddPicture(string parentPath, string type, InsertPosition? position, Dictionary<string, string> properties)\n    {\n        var index = position?.Index;\n        var picSegments = parentPath.TrimStart('/').Split('/', 2);\n        var picSheetName = picSegments[0];\n        var picWorksheet = FindWorksheet(picSheetName)\n            ?? throw new ArgumentException($\"Sheet not found: {picSheetName}\");\n\n        if (!properties.TryGetValue(\"path\", out var imgPath)\n            && !properties.TryGetValue(\"src\", out imgPath))\n            throw new ArgumentException(\"'src' property is required for picture type\");\n\n        // CONSISTENCY(picture-emu): use ParseAnchorBoundsEmu like OLE,\n        // so width/height accept unit-qualified strings (\"6cm\", \"2in\")\n        // in addition to bare integer cell counts.\n        var (px, py, pwEmu, phEmu) = ParseAnchorBoundsEmu(properties, \"0\", \"0\", \"5\", \"5\");\n        // P9: accept `altText=` as alias for `alt=`.\n        // CONSISTENCY(picture-alt): description completes the shared alias set.\n        var alt = properties.GetValueOrDefault(\"alt\")\n            ?? properties.GetValueOrDefault(\"altText\")\n            ?? properties.GetValueOrDefault(\"alttext\")\n            ?? properties.GetValueOrDefault(\"description\", \"\");\n\n        // Resolve the image bytes AND parse/validate the anchor BEFORE any\n        // part is created: a bad data URI or anchor used to fail after the","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Add.Drawings.cs#L252-L288","documentation":"Thrown by AddPicture when the sheet name extracted from the parentPath does not resolve to an existing worksheet. The path is split on the first '/' and the first segment is treated as the sheet name; if FindWorksheet returns null, the error fires before any image-path validation.","triggerScenarios":"Calling add /NonExistentSheet --type picture --src logo.png. The worksheet with that name does not exist in the workbook.","commonSituations":"Sheet renamed or deleted. Case or whitespace mismatch. Script targets a sheet from a different workbook.","solutions":["List worksheets to get the exact sheet name.","Check for casing and trailing-space issues.","Create the sheet first if it should exist."],"exampleFix":"// before (sheet is 'Cover')\nadd /cover --type picture --src logo.png\n// after\nadd /Cover --type picture --src logo.png","handlingStrategy":"validation","validationCode":"// Check the sheet exists before calling AddPicture\nvar sheetName = parentPath.TrimStart('/').Split('/', 2)[0];\nif (handler.FindWorksheet(sheetName) == null)\n    throw new InvalidOperationException($\"Sheet not found: {sheetName}\");","typeGuard":null,"tryCatchPattern":"try { handler.AddPicture(parentPath, type, position, properties); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Sheet not found:\"))\n{\n    Console.Error.WriteLine($\"{ex.Message} Verify the sheet name.\");\n}","preventionTips":["List worksheets and verify the exact name before the add call.","Check casing and trailing whitespace.","Create the sheet first if it does not exist."],"tags":["excel","picture","sheet-not-found","validation"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}