Get Started
Documentation

AddImage

AddImage(sImageSrc, nWidth, nHeight, nFromCol, nColOffset, nFromRow, nRowOffset) → {ApiImage}

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

Parameters:

Name Type Description
sImageSrc string The image source where the image to be inserted should be taken from (currently only internet URL or Base64 encoded images are supported).
nWidth EMU The image width in English measure units.
nHeight EMU The image height in English measure units.
nFromCol number The number of the column where the beginning of the image will be placed.
nColOffset EMU The offset from the nFromCol column to the left part of the image measured in English measure units.
nFromRow number The number of the row where the beginning of the image will be placed.
nRowOffset EMU The offset from the nFromRow row to the upper part of the image measured in English measure units.
Please note, that the horizontal nColOffset and vertical nRowOffset offsets are calculated within the limits of the specified nFromCol column and nFromRow row cell only. If this value exceeds the cell width or height, another vertical/horizontal position will be set.

Returns:

Type
ApiImage

Example

Copy code
builder.CreateFile("xlsx");
var oWorksheet = Api.GetActiveSheet();
oWorksheet.AddImage("https://api.onlyoffice.com/content/img/docbuilder/examples/coordinate_aspects.png", 60 * 36000, 35 * 36000, 0, 2 * 36000, 0, 3 * 36000);
builder.SaveFile("xlsx", "AddImage.xlsx");
builder.CloseFile();

Resulting document