iOfficeAI/OfficeCLI · error · ArgumentException

'name' property is not supported for Excel OLE (Spreadsheet

Error message

'name' property is not supported for Excel OLE (Spreadsheet OleObject schema has no Name attribute). Remove --prop name.

What it means

Thrown when the 'name' property is present on an Excel OLE-add call. The SpreadsheetML x:oleObject element has no Name attribute in the schema, so there is nowhere to persist a name. The property is kept in KnownOleProps (so Word/PPT still accept it) but Excel Add throws explicitly rather than silently dropping the value. This mirrors the display= rejection for consistency.

Source

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

        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);

        // 3. Resolve ProgID.
        var oleProgId = OfficeCli.Core.OleHelper.ResolveProgId(properties, oleSrc);

        // 4. Anchor: accept either cell range "B2:E6" or x/y/width/height (column units).
        // CONSISTENCY(ole-width-units): sub-cell precision is carried in
        // ColumnOffset/RowOffset (EMU) so unit-qualified widths like
        // "6cm" survive a round-trip. When the user passes a cell range
        // or a bare integer cell count, the remainder offsets are 0 and
        // behavior matches the legacy whole-cell path.

View on GitHub (pinned to 1ced45e900)

Solutions

  1. Remove the --prop name=... argument from the Excel OLE add call.
  2. If you need to name an embedded object, use Word or PowerPoint OLE instead.
  3. Track OLE object identity via the returned path (/Sheet1/ole[N]) instead of a name.

Example fix

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

Strategy: validation

Validate before calling

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

Try / catch

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

Prevention

When it happens

Trigger: Calling add /Sheet1 --type ole --src obj.docx --prop name=MyObject. The ContainsKey("name") check fires and throws, even though the same property works for Word/PPT OLE objects.

Common situations: User applies a cross-application OLE property set (name, display) from Word/PPT scripts to Excel. User expects to label the OLE object for later retrieval.

Related errors


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