iOfficeAI/OfficeCLI · error · CliException
unsupported_type
unsupported_type
Error message
Import is only supported for .xlsx files in V1
What it means
The import command only supports .xlsx workbooks as the import target in V1. This fires when the target file exists but has an extension other than .xlsx (e.g. .docx, .pptx, .csv).
Source
Thrown at src/officecli/CommandBuilder.Import.cs:55
{
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.ReadAllText
// (the --file branch below) drops a UTF-8 BOM implicitly, the
// stdin reader hands it through. Without this, `import --stdin`
// fed a BOM'd CSV put a stray U+FEFF inside the first header
// cell while `import --file` on the same bytes did not.
csvContent = StripBom(StdIn.ReadToEnd());
}
else if (source != null)
{View on GitHub (pinned to 1ced45e900)
Solutions
- Switch the target to a .xlsx workbook.
- If you need a new spreadsheet, 'officecli create out.xlsx' first.
Example fix
// before officecli import summary.docx --file data.csv // after officecli import summary.xlsx --file data.csv
Defensive patterns
Strategy: validation
Validate before calling
var ext = Path.GetExtension(targetXlsx).ToLowerInvariant();
if (ext != ".xlsx")
throw new ArgumentException($"Import target must be .xlsx, got '{ext}'."); Type guard
static bool IsXlsxTarget(string f) =>
Path.GetExtension(f).Equals(".xlsx", StringComparison.OrdinalIgnoreCase); Prevention
- The import target is always xlsx in V1; CSV/TSV is the source, not the target.
- Validate target extension before invoking import.
When it happens
Trigger: 'officecli import notes.docx --file data.csv' or any import whose target file extension is not .xlsx.
Common situations: Reusing an existing non-spreadsheet document as the import target; confusing the import source (CSV/TSV) with the target (must be xlsx).
Related errors
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/99118cc0ae4b2dd3.
Report an issue: GitHub.