AddShape

function AddShape(
  sType: ShapeType = "rect",
  nWidth: EMU = null,
  nHeight: EMU = null,
  oFill: ApiFill = null,
  oStroke: ApiStroke = null,
  nFromCol: number = null,
  nColOffset: EMU = null,
  nFromRow: number = null,
  nRowOffset: EMU = null,
): ApiShape

Description

Adds a shape to the current sheet with the parameters specified. Please note that the horizontal and vertical offsets are calculated within the limits of the specified column and row cells only. If this value exceeds the cell width or height, another vertical/horizontal position will be set.

Parameters

sTypeShapeTypedefault: "rect"

The shape type which specifies the preset shape geometry.

nWidthEMUdefault: null

The shape width in English measure units.

nHeightEMUdefault: null

The shape height in English measure units.

oFillApiFilldefault: null

The color or pattern used to fill the shape.

oStrokeApiStrokedefault: null

The stroke used to create the element shadow.

nFromColnumberdefault: null

The number of the column where the beginning of the shape will be placed.

nColOffsetEMUdefault: null

The offset from the nFromCol column to the left part of the shape measured in English measure units.

nFromRownumberdefault: null

The number of the row where the beginning of the shape will be placed.

nRowOffsetEMUdefault: null

The offset from the nFromRow row to the upper part of the shape measured in English measure units.

Returns

ApiShape

Try It

var oWorksheet = Api.GetActiveSheet();
var oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(255, 213, 191), 0);
var oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(255, 111, 61), 100000);
var oFill = Api.CreateLinearGradientFill([oGs1, oGs2], 5400000);
var oStroke = Api.CreateStroke(0, Api.CreateNoFill());
oWorksheet.AddShape("flowChartOnlineStorage", 60 * 36000, 35 * 36000, oFill, oStroke, 0, 2 * 36000, 0, 3 * 36000);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).