{"record":{"id":"e8fb3c4c57929fbd","repo":"iOfficeAI/OfficeCLI","slug":"file-not-found-e8fb3c","errorCode":"file_not_found","errorMessage":"File not found: {file.FullName}","messagePattern":"File not found: (.+?)","errorType":"exception","errorClass":"CliException","httpStatus":null,"severity":"error","filePath":"src/officecli/CommandBuilder.Import.cs","lineNumber":47,"sourceCode":"        importCommand.Add(importSourceOpt);\n        importCommand.Add(importStdinOpt);\n        importCommand.Add(importFormatOpt);\n        importCommand.Add(importHeaderOpt);\n        importCommand.Add(importStartCellOpt);\n        importCommand.Add(jsonOption);\n\n        importCommand.SetAction(result => { var json = result.GetValue(jsonOption); return SafeRun(() =>\n        {\n            var file = result.GetValue(importFileArg)!;\n            var parentPath = OfficeCli.Core.MsysPathHint.Restore(result.GetValue(importParentPathArg)!)!;\n            var source = result.GetValue(importSourceOpt) ?? result.GetValue(importSourceArg);\n            var useStdin = result.GetValue(importStdinOpt);\n            var format = result.GetValue(importFormatOpt);\n            var header = result.GetValue(importHeaderOpt);\n            var startCell = result.GetValue(importStartCellOpt)!;\n\n            if (!file.Exists)\n                throw new CliException($\"File not found: {file.FullName}\")\n                {\n                    Code = \"file_not_found\",\n                    Suggestion = $\"Create the file first: officecli create \\\"{file.FullName}\\\"\"\n                };\n\n            var ext = Path.GetExtension(file.FullName).ToLowerInvariant();\n            if (ext != \".xlsx\")\n                throw new CliException(\"Import is only supported for .xlsx files in V1\")\n                {\n                    Code = \"unsupported_type\",\n                    Suggestion = \"Use a .xlsx file\"\n                };\n\n            // Read CSV content\n            string csvContent;\n            if (useStdin)\n            {\n                // StripBom for the same reason batch does it: File.ReadAllText","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/CommandBuilder.Import.cs#L29-L65","documentation":"The import command requires an existing target .xlsx workbook to import data into; it imports CSV/TSV content into a spreadsheet, it does not create one. This fires when the target file (the positional <file> argument) does not exist on disk.","triggerScenarios":"Running 'officecli import <target>.xlsx --file data.csv' (or --stdin) where <target>.xlsx does not exist; a typo'd or not-yet-created target path.","commonSituations":"Assuming 'import' creates the workbook (it does not — use 'create' first); pointing at the wrong directory; an agent retrying against a path it cleaned up.","solutions":["Create the target workbook first: 'officecli create \"<target>.xlsx\"'.","Verify the path: check spelling and working directory.","If importing into a freshly-built file, chain create then import."],"exampleFix":"// before\nofficecli import report.xlsx --file data.csv   # report.xlsx missing\n// after\nofficecli create report.xlsx\nofficecli import report.xlsx --file data.csv","handlingStrategy":"validation","validationCode":"if (!File.Exists(targetXlsx))\n    throw new FileNotFoundException(\n        $\"Target workbook missing — create it first: officecli create \\\"{targetXlsx}\\\"\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat 'import' as write-into-existing, not create; precede with 'create' for new workbooks.","Stat the target file before the import call in automation scripts.","Remember import is .xlsx-only in V1."],"tags":["file-io","import","file-not-found","xlsx"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}