Skip to main content

AddImage

Adds an image to the current sheet with the parameters specified.

Syntax​

expression.AddImage(sImageSrc, nWidth, nHeight, nFromCol, nColOffset, nFromRow, nRowOffset);

expression - A variable that represents a ApiWorksheet class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
sImageSrcRequiredstringThe image source where the image to be inserted should be taken from (currently only internet URL or Base64 encoded images are supported).
nWidthRequiredEMUThe image width in English measure units.
nHeightRequiredEMUThe image height in English measure units.
nFromColRequirednumberThe number of the column where the beginning of the image will be placed.
nColOffsetRequiredEMUThe offset from the nFromCol column to the left part of the image measured in English measure units.
nFromRowRequirednumberThe number of the row where the beginning of the image will be placed.
nRowOffsetRequiredEMUThe offset from the nFromRow row to the upper part of the image measured in English measure units.

Returns​

ApiImage

Example​

Place an image onto a sheet at a specific position and size in a spreadsheet.

// How do I embed a picture from a URL into my sheet in a spreadsheet?

// Decorate a worksheet by inserting an image with defined dimensions and placement.

let worksheet = Api.GetActiveSheet();
worksheet.AddImage("https://static.onlyoffice.com/assets/docs/samples/img/presentation_sky.png", 60 * 36000, 35 * 36000, 0, 2 * 36000, 0, 3 * 36000);