{"record":{"id":"4e8c8b4baffa8876","repo":"iOfficeAI/OfficeCLI","slug":"sharedstring-entry-sstidx-not-found","errorCode":null,"errorMessage":"SharedString entry {sstIdx} not found","messagePattern":"SharedString entry (.+?) not found","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Query.cs","lineNumber":933,"sourceCode":"            return GenericXmlQuery.ElementToNode(target, path, depth);\n        }\n\n        // Handle /SheetName/A1/run[N] (rich text run direct access)\n        var runGetMatch = Regex.Match(cellRef, @\"^([A-Z]+\\d+)/run\\[(\\d+)\\]$\", RegexOptions.IgnoreCase);\n        if (runGetMatch.Success)\n        {\n            var runCellRef = runGetMatch.Groups[1].Value.ToUpperInvariant();\n            var runIdx = int.Parse(runGetMatch.Groups[2].Value);\n            ParseCellReference(runCellRef);\n            var runCell = FindCell(data, runCellRef);\n            if (runCell == null)\n                throw new ArgumentException($\"Cell {runCellRef} not found\");\n            if (runCell.DataType?.Value != CellValues.SharedString ||\n                !int.TryParse(runCell.CellValue?.Text, out var sstIdx))\n                throw new ArgumentException($\"Cell {runCellRef} is not a rich text cell\");\n            var sstPart = _doc.WorkbookPart?.GetPartsOfType<SharedStringTablePart>().FirstOrDefault();\n            var ssi = sstPart?.SharedStringTable?.Elements<SharedStringItem>().ElementAtOrDefault(sstIdx);\n            if (ssi == null) throw new ArgumentException($\"SharedString entry {sstIdx} not found\");\n            var runs = ssi.Elements<Run>().ToList();\n            if (runIdx < 1 || runIdx > runs.Count)\n                throw new ArgumentException($\"Run index {runIdx} out of range (1-{runs.Count})\");\n            return RunToNode(runs[PathIndex.ToArrayIndex(runIdx)], $\"/{sheetNameFromPath}/{runCellRef}/run[{runIdx}]\");\n        }\n\n        if (cellRef.Contains(':'))\n        {\n            // Range — validate both endpoints\n            var rangeParts = cellRef.Split(':');\n            ParseCellReference(rangeParts[0]);\n            if (rangeParts.Length > 1) ParseCellReference(rangeParts[1]);\n            return GetCellRange(sheetNameFromPath, data, cellRef, depth, worksheet);\n        }\n        else\n        {\n            // Single cell — validate cell reference\n            ParseCellReference(cellRef);","sourceCodeStart":915,"sourceCodeEnd":951,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Query.cs#L915-L951","documentation":"Thrown in the run[N] path when the cell IS a SharedString cell and points at index sstIdx, but the SharedStringTable has no entry at that index (ElementAtOrDefault returns null). This indicates a corrupt or hand-edited file whose cell references a shared-string index that does not exist — the data is internally inconsistent.","triggerScenarios":"A cell whose CellValue is an integer but that integer exceeds the SharedStringTable entry count, or the table is missing entirely. Reached only for cells that passed the 'is rich text cell' check (DataType == SharedString, integer value) but whose index is stale.","commonSituations":"Files edited by non-conforming tools, partial/corrupt exports, manual XML edits to sheetData or sharedStrings.xml that desynchronize the index, or a file where the shared-strings part was stripped.","solutions":["Open and re-save the workbook in Excel/another conforming writer to rebuild the shared-strings table.","Validate the file with the Open XML SDK or an OOXML validator to locate the desynchronization.","If you control the producer, ensure every SharedString cell value is written through the SharedStringTable, not hand-set."],"exampleFix":"// no code fix — repair the source workbook so shared-string indices are valid","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try:\n    doc.get('/Sheet1/A1/run[1]')\nexcept officecli.OfficeCliError as e:\n    if 'SharedString entry' in str(e):\n        # corrupt file: shared-string index is stale\n        repair_or_reexport_workbook(path)","preventionTips":["Validate the OOXML with the Open XML SDK before querying runs.","Re-save corrupt files in Excel to rebuild the shared-strings table.","Avoid hand-editing sheetData/sharedStrings.xml; always write through a conforming producer."],"tags":["excel","shared-string","corrupt-file","not-found","get"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}