iOfficeAI/OfficeCLI · error · CliException
file_not_found
file_not_found
Error message
File not found: {file.FullName} What it means
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.
Source
Thrown at src/officecli/CommandBuilder.Import.cs:47
importCommand.Add(importSourceOpt);
importCommand.Add(importStdinOpt);
importCommand.Add(importFormatOpt);
importCommand.Add(importHeaderOpt);
importCommand.Add(importStartCellOpt);
importCommand.Add(jsonOption);
importCommand.SetAction(result => { var json = result.GetValue(jsonOption); return SafeRun(() =>
{
var file = result.GetValue(importFileArg)!;
var parentPath = OfficeCli.Core.MsysPathHint.Restore(result.GetValue(importParentPathArg)!)!;
var source = result.GetValue(importSourceOpt) ?? result.GetValue(importSourceArg);
var useStdin = result.GetValue(importStdinOpt);
var format = result.GetValue(importFormatOpt);
var header = result.GetValue(importHeaderOpt);
var startCell = result.GetValue(importStartCellOpt)!;
if (!file.Exists)
throw new CliException($"File not found: {file.FullName}")
{
Code = "file_not_found",
Suggestion = $"Create the file first: officecli create \"{file.FullName}\""
};
var ext = Path.GetExtension(file.FullName).ToLowerInvariant();
if (ext != ".xlsx")
throw new CliException("Import is only supported for .xlsx files in V1")
{
Code = "unsupported_type",
Suggestion = "Use a .xlsx file"
};
// Read CSV content
string csvContent;
if (useStdin)
{
// StripBom for the same reason batch does it: File.ReadAllTextView on GitHub (pinned to 1ced45e900)
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.
Example fix
// before officecli import report.xlsx --file data.csv # report.xlsx missing // after officecli create report.xlsx officecli import report.xlsx --file data.csv
Defensive patterns
Strategy: validation
Validate before calling
if (!File.Exists(targetXlsx))
throw new FileNotFoundException(
$"Target workbook missing — create it first: officecli create \"{targetXlsx}\""); Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/e8fb3c4c57929fbd.
Report an issue: GitHub.