{"record":{"id":"8a35e69fcc84a5d8","repo":"iOfficeAI/OfficeCLI","slug":"sheet-not-found-catsheetname","errorCode":null,"errorMessage":"Sheet not found: {catSheetName}","messagePattern":"Sheet not found: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Helpers.Chart.cs","lineNumber":662,"sourceCode":"        if (bangIdx >= 0)\n        {\n            catSheetName = rangePart[..bangIdx].Trim('\\'');\n            rangePart = rangePart[(bangIdx + 1)..];\n        }\n\n        var cleanRange = rangePart.Replace(\"$\", \"\");\n        var rangeParts = cleanRange.Split(':');\n        if (rangeParts.Length != 2)\n            throw new ArgumentException(\n                $\"Invalid categories range: '{explicitValue}'. Expected format: 'Sheet1!A2:A3' or 'A2:A3'.\");\n\n        var (startCol, startRow) = ParseCellReference(rangeParts[0]);\n        var (endCol, endRow) = ParseCellReference(rangeParts[1]);\n        var startColIdx = ColumnNameToIndex(startCol);\n        var endColIdx = ColumnNameToIndex(endCol);\n\n        var ws = FindWorksheet(catSheetName)\n            ?? throw new ArgumentException($\"Sheet not found: {catSheetName}\");\n        var sheetData = GetSheet(ws).GetFirstChild<SheetData>()\n            ?? throw new ArgumentException($\"Sheet '{catSheetName}' has no data\");\n\n        // Read the explicit-range cells directly (rows may differ from dataRange).\n        var lookup = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);\n        foreach (var row in sheetData.Elements<Row>())\n        {\n            var rowIdx = (int)(row.RowIndex?.Value ?? 0);\n            if (rowIdx < startRow || rowIdx > endRow) continue;\n            foreach (var cell in row.Elements<Cell>())\n                if (cell.CellReference?.Value != null)\n                    lookup[cell.CellReference.Value] = GetCellDisplayValue(cell);\n        }\n\n        var labels = new List<string>();\n        for (int r = startRow; r <= endRow; r++)\n            for (int c = startColIdx; c <= endColIdx; c++)\n            {","sourceCodeStart":644,"sourceCodeEnd":680,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Helpers.Chart.cs#L644-L680","documentation":"Same sheet resolution as error 671 but for the categories sheet prefix. After splitting '!' off the categories ref, FindWorksheet(catSheetName) returns null and throws the terse 'Sheet not found'. Same case-insensitive name + sheet[N]/sheet[last] alias resolution.","triggerScenarios":"categories=RenamedSheet!A2:A3; a categories ref whose sheet prefix was renamed or deleted.","commonSituations":"Categories sheet renamed after authoring; sheet deleted; typo in the prefix.","solutions":["Verify the sheet exists (GetDumpSheetNames) before charting.","Use a positional alias sheet[N] if you only know the index.","Drop the explicit categories to fall back to defaults.","Re-author the categories ref against the current sheet name."],"exampleFix":"// before\nprops[\"categories\"] = \"OldCats!A2:A10\";  // sheet renamed -> throw\n\n// after\nprops[\"categories\"] = \"Labels!A2:A10\";  // current name","handlingStrategy":"validation","validationCode":"var sheet = cats.Contains('!') ? cats[..cats.IndexOf('!')].Trim('\\'') : defaultSheet;\nif (!handler.GetDumpSheetNames().Contains(sheet, StringComparer.OrdinalIgnoreCase))\n    throw new ArgumentException($\"categories sheet '{sheet}' does not exist\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the categories sheet exists before charting.","Use a positional alias when only the index is known.","Drop explicit categories to fall back to defaults if the sheet is gone."],"tags":["excel","ooxml","chart","sheets","validation"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}