Table of Contents

Method Add

Namespace
DocWright.Spreadsheet
Assembly
DocWright.Spreadsheet.dll

Add(Stream, string, Stream, string, XlsxEmbeddedObjectOptions?)

Embeds a file as a packaged object shown as an icon, its top-left corner in a cell, as Excel's "Insert, Object, Create from file, Display as icon" does: the file wrapped in Windows' Packager container, the icon picture the caller gives (Excel draws one from the file's type; this library draws none).

public XlsxEmbeddedObject Add(Stream content, string fileName, Stream iconPicture, string cell, XlsxEmbeddedObjectOptions? options = null)

Parameters

content Stream

The file's bytes, read from where the stream stands to its end.

fileName string

The file's name (not a path), as Excel shows it under the icon and names the file it unpacks.

iconPicture Stream

A PNG or JPEG image shown for the object.

cell string

The cell, such as C3.

options XlsxEmbeddedObjectOptions

The name and the size; null for Excel's name and the picture's size.

Returns

XlsxEmbeddedObject

The object.

Exceptions

ArgumentNullException

An argument is null.

ArgumentException

The name is empty, a path or more than 255 characters; the picture is not a PNG or JPEG image; the cell or a size is refused; or the name is another object's.

ResourceLimitExceededException

The picture states more pixels than the workbook's settings allow.

InvalidOperationException

The sheet is not a worksheet, or its drawings hold more objects than one legacy drawing block.