Table of Contents

Method Add

Namespace
DocWright.Spreadsheet
Assembly
DocWright.Spreadsheet.dll

Add(byte[], string, XlsxPictureOptions?)

Adds a picture whose top-left corner is in a cell, the image's bytes stored as they are.

public XlsxPicture Add(byte[] data, string cell, XlsxPictureOptions? options = null)

Parameters

data byte[]

A PNG or JPEG image.

cell string

The cell, such as B4.

options XlsxPictureOptions

The size, placement, name and alternative text; null for the image's own size, placed as Excel places a new picture.

Returns

XlsxPicture

The picture.

Exceptions

ArgumentException

The bytes are not a PNG or JPEG image whose header states its size, the cell is not a cell reference, or a size or offset is not positive or is past what a drawing states.

ResourceLimitExceededException

The image states more pixels than MaxImagePixels of the settings the workbook was opened with.

InvalidOperationException

The sheet is not a worksheet.

InvalidDocumentException

A part of the workbook is malformed.

Add(Stream, string, XlsxPictureOptions?)

Adds a picture whose top-left corner is in a cell, the image read from a stream and stored as it is.

public XlsxPicture Add(Stream data, string cell, XlsxPictureOptions? options = null)

Parameters

data Stream

A stream of a PNG or JPEG image, read from where it stands to its end.

cell string

The cell, such as B4.

options XlsxPictureOptions

See Add(byte[], string, XlsxPictureOptions?).

Returns

XlsxPicture

The picture.

Exceptions

ArgumentException

See Add(byte[], string, XlsxPictureOptions?).

ResourceLimitExceededException

See Add(byte[], string, XlsxPictureOptions?).

InvalidOperationException

The sheet is not a worksheet.

InvalidDocumentException

A part of the workbook is malformed.