AddShape
Adds the shape to the current sheet with the parameters specified.
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.
Parameters:
Name |
Type |
Default |
Description |
sType |
ShapeType
|
"rect" |
The shape type which specifies the preset shape geometry. |
nWidth |
EMU
|
|
The shape width in English measure units. |
nHeight |
EMU
|
|
The shape height in English measure units. |
oFill |
ApiFill
|
|
The color or pattern used to fill the shape. |
oStroke |
ApiStroke
|
|
The stroke used to create the element shadow. |
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 shape 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 shape measured in English measure units. |
Returns:
- Type
-
ApiShape
Example
Copy code
builder.CreateFile("xlsx");
oWorksheet = Api.GetActiveSheet();
oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(255, 224, 204), 0);
oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(255, 164, 101), 100000);
oFill = Api.CreateLinearGradientFill([oGs1, oGs2], 5400000);
oStroke = Api.CreateStroke(0, Api.CreateNoFill());
oWorksheet.AddShape("flowChartOnlineStorage", 60 * 36000, 35 * 36000, oFill, oStroke, 0, 2 * 36000, 0, 3 * 36000);
builder.SaveFile("xlsx", "AddShape.xlsx");
builder.CloseFile();
Resulting document