[]
• new ShapeCollection(sheet
)
Represents a shape manager that managers all shapes in a sheet.
Name | Type | Description |
---|---|---|
sheet |
Worksheet |
The worksheet. |
▸ add(name
, autoShapeTypeOrModel
, left?
, top?
, width?
, height?
): Shape
Add a new shape to shape collection
example
// This example shows how to add a new shape
var shape = activeSheet.shapes.add("shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 50, 100, 150);
Name | Type | Description |
---|---|---|
name |
string |
The name of the shape. If leave blank an unique name will be generated. |
autoShapeTypeOrModel |
IShapeModel | AutoShapeType |
The type of the shape (for one of the buildin types) or the model for custom shape. |
left? |
number |
The x location of the shape. |
top? |
number |
The y location of the shape. |
width? |
number |
The width of the shape. |
height? |
number |
The height of the shape. |
The shape that has been added to the sheet.
▸ addCameraShape(name
, range
, left?
, top?
, width?
, height?
): CameraShape
Add a new camera shape to shape collection
example
// This example shows how to add a new camera shape
var shape = activeSheet.shapes.addCameraShape("camera shape 1", 'Sheet1!A1:A8', 100, 50, 100, 150);
Name | Type | Description |
---|---|---|
name |
string |
The name of the camera shape. If leave blank an unique name will be generated. |
range |
string |
The range of the shape generated from, it should be a range formula, like Sheet1!A1:A8. |
left? |
number |
- |
top? |
number |
- |
width? |
number |
- |
height? |
number |
- |
The shape that has been added to the sheet.
▸ addConnector(name
, connectorType
, beginX?
, beginY?
, endX?
, endY?
): ConnectorShape
Add a Connector Shape to shape collection
example
//This example shows how to add a connector shape
var shape1 = activeSheet.shapes.addConnector("shape1", GC.Spread.Sheets.Shapes.ConnectorType.elbow, 200, 50, 300, 200);
Name | Type | Description |
---|---|---|
name |
string |
The name of the shape. If leave blank an unique name will be generated. |
connectorType |
ConnectorType |
The type of the connector. |
beginX? |
number |
The x location of the start point for the connector shape. |
beginY? |
number |
The y location of the start point for the connector shape. |
endX? |
number |
The x location of the end point for the connector shape. |
endY? |
number |
The y location of the end point for the connector shape. |
The connector shape that has been added to the sheet.
▸ addPictureShape(name
, src
, left?
, top?
, width?
, height?
): PictureShape
Add a new picture shape to shape collection
example
// This example shows how to add a new picture shape
var shape = activeSheet.shapes.addPictureShape("Picture 1", "data:image/svg+xml;base64.....", 100, 50, 100, 100);
Name | Type | Description |
---|---|---|
name |
string |
The name of the shape. If leave blank an unique name will be generated. |
src |
string |
The src of the picture. |
left? |
number |
The x location of the picture shape. |
top? |
number |
The y location of the picture shape. |
width? |
number |
The width of the picture shape. |
height? |
number |
The height of the picture shape. |
The picture shape that has been added to the sheet.
▸ all(): Shape
[]
get all shapes
example
// This sample shows how to get all shapes in shape collection
activeSheet.shapes.add("shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 50, 100, 150);
activeSheet.shapes.addConnector("shape2", GC.Spread.Sheets.Shapes.ConnectorType.elbow, 200, 50, 300, 200);
var shapes = activeSheet.shapes.all();
Shape
[]
all shapes
▸ clear(): void
clear all shapes
example
//This example shows how to clear all shapes in shape collection
activeSheet.shapes.add("shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 50, 100, 150);
activeSheet.shapes.addConnector("shape2", GC.Spread.Sheets.Shapes.ConnectorType.elbow, 200, 50, 300, 200);
activeSheet.shapes.clear();
void
▸ get(name
): Shape
Get a shape with name
example
//This example shows how to get a shape with name.
activeSheet.shapes.add("shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 50, 100, 150);
activeSheet.shapes.get("shape1");
Name | Type | Description |
---|---|---|
name |
string |
The name of the shape. |
The Shape
▸ group(shapes
): GroupShape
Groups the Shapes.
example
//This sample shows how to group some shapes
var shape1 = activeSheet.shapes.add("shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 50, 100, 150);
var shape2 = activeSheet.shapes.addConnector("shape2", GC.Spread.Sheets.Shapes.ConnectorType.elbow, 200, 50, 300, 200);
var shapes = [shape1, shape2];
var groupShape = activeSheet.shapes.group(shapes)
Name | Type | Description |
---|---|---|
shapes |
Shape [] |
The shapes to group. |
The Shape group.
▸ remove(name
): void
remove a shape
example
//This example shows how to remove a shape
activeSheet.shapes.add("shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 50, 100, 150);
activeSheet.shapes.remove("shape1");
Name | Type | Description |
---|---|---|
name |
string |
The name of the shape. |
void
▸ snapMode(value?
): void
| SnapMode
Gets or sets whether to align shape to grid line or the other shapes.
example
sheet1.shapes.SnapMode(GC.Spread.Sheets.Shapes.SnapMode.grid);
var snapMode = sheet1.shapes.snapMode();
Name | Type | Description |
---|---|---|
value? |
SnapMode |
Whether to snap shapes to the grid line or other shapes. |
void
| SnapMode
If no value is set, returns which snapMode use.
▸ ungroup(groupShape
): void
Separate a groupShape to some shapes
example
//This sample shows how to separate a groupShape to some shapes
var shape1 = activeSheet.shapes.add("shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 50, 100, 150);
var shape2 = activeSheet.shapes.addConnector("shape2", GC.Spread.Sheets.Shapes.ConnectorType.elbow, 200, 50, 300, 200);
var shapes = [shape1, shape2];
var groupShape = activeSheet.shapes.group(shapes);
activeSheet.shapes.ungroup(groupShape);
Name | Type | Description |
---|---|---|
groupShape |
GroupShape |
The groupShape to separate. |
void
▸ zIndex(shapeName
, zIndex
): number
Get or set the z-index for a shape
example
//This is a sample shows how to use zIndex.
var shape1 = activeSheet.shapes.add("shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 50, 100, 150);
var style = shape1.style();
style.fill.color = "red";
shape1.style(style);
var shape2 = activeSheet.shapes.addConnector("shape2", GC.Spread.Sheets.Shapes.ConnectorType.elbow, 100, 50, 200, 200);
activeSheet.shapes.zIndex("shape2"); // 1
activeSheet.shapes.zIndex("shape2", 0);
Name | Type | Description |
---|---|---|
shapeName |
string |
The name of the shape |
zIndex |
number |
The z-index for the shape. The zIndex should be between 0 to all shapes length(not contains). A shape with greater zIndex is always in front of a shape with a lower zIndex. |
number