iOfficeAI/OfficeCLI · error · ArgumentException

'display' property is not supported for Excel OLE (Excel alw

Error message

'display' property is not supported for Excel OLE (Excel always shows objects as icon). Remove --prop display.

What it means

Thrown when the 'display' property is present on an OLE-add call for Excel. Excel OLE objects are always shown as icons via objectPr/anchor — there is no DrawAspect concept — so 'display' would be a no-op. The Add handler rejects it explicitly for symmetry with the Set handler, rather than silently dropping the value.

Source

Thrown at src/officecli/Handlers/Excel/ExcelHandler.Add.Drawings.cs:99

        // OLE payload real Excel refuses (0x800A03EC). Reject up front.
        try
        {
            if (!string.IsNullOrEmpty(oleSrc) && !string.IsNullOrEmpty(_filePath)
                && string.Equals(Path.GetFullPath(oleSrc), Path.GetFullPath(_filePath),
                    StringComparison.OrdinalIgnoreCase))
                throw new ArgumentException(
                    "Cannot embed a workbook into itself: the source file is the workbook being edited. "
                    + "Embed a different file, or make a copy of the source first.");
        }
        catch (ArgumentException) { throw; }
        catch { /* path canonicalization failed — fall through to normal read */ }

        // CONSISTENCY(excel-ole-display): Excel OLE does not have a
        // DrawAspect concept — worksheet objects are always shown as
        // icons via objectPr/anchor, so 'display' would be a no-op.
        // Set already rejects it; Add must too, for symmetry.
        if (properties.ContainsKey("display"))
            throw new ArgumentException(
                "'display' property is not supported for Excel OLE "
                + "(Excel always shows objects as icon). Remove --prop display.");

        // CONSISTENCY(ole-name): Word/PPT OLE accept --prop name=... and
        // round-trip it via Get. SpreadsheetML x:oleObject has no Name
        // attribute in the schema, so there is nowhere to persist it.
        // Throw explicitly rather than silently dropping the value —
        // keep 'name' in KnownOleProps so Word/PPT still accept it.
        if (properties.ContainsKey("name"))
            throw new ArgumentException(
                "'name' property is not supported for Excel OLE "
                + "(Spreadsheet OleObject schema has no Name attribute). Remove --prop name.");

        // 1. Embedded payload.
        var (oleEmbedRelId, _) = OfficeCli.Core.OleHelper.AddEmbeddedPart(oleWorksheet, oleSrc, _filePath);

        // 2. Icon preview image part.
        var (_, oleIconRelId) = OfficeCli.Core.OleHelper.CreateIconPart(oleWorksheet, properties);

View on GitHub (pinned to 1ced45e900)

Solutions

  1. Remove the --prop display=... argument from the OLE add call for Excel.
  2. Excel always shows OLE objects as icons; no property controls this.
  3. If you need display control, use Word or PowerPoint OLE instead.

Example fix

// before
add /Sheet1 --type ole --src data.xlsx --prop display=icon
// after
add /Sheet1 --type ole --src data.xlsx
Defensive patterns

Strategy: validation

Validate before calling

// Remove unsupported 'display' property before Excel OLE add
if (properties.ContainsKey("display"))
{
    properties.Remove("display");
    Console.Error.WriteLine("Warning: 'display' is not supported for Excel OLE and was removed.");
}

Try / catch

try { handler.AddOle(parentPath, properties); }
catch (ArgumentException ex) when (ex.Message.Contains("'display' property is not supported"))
{
    properties.Remove("display");
    // retry without display
    handler.AddOle(parentPath, properties);
}

Prevention

When it happens

Trigger: Calling add /Sheet1 --type ole --src obj.docx --prop display=icon (or display=content). The ContainsKey check fires regardless of the value; even display=icon is rejected because the property has no effect in the Excel OLE schema.

Common situations: User migrates a script from Word or PowerPoint OLE (which supports display=) to Excel and reuses the same properties. User assumes display= controls icon-vs-content rendering like in Word.

Related errors


AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13). Data as JSON: /api/errors/af6ad45c769c49e0. Report an issue: GitHub.