[]
ShapeBase
↳ Shape
• new ShapeBase()
表示 Shape、GroupShape 和 ConnectorShape 的基类。
▸ allowMove(value?): any
获取或设置是否禁用移动形状。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var state = heart.allowMove();
heart.allowMove(!state);
| Name | Type | Description |
|---|---|---|
value? |
boolean |
是否禁用移动形状的设置。 |
any
如果未设置值,返回是否禁用移动形状的设置。
▸ allowResize(value?): any
获取或设置形状的调整大小模式。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var state = heart.allowResize();
heart.allowResize(GC.Spread.Sheets.Shapes.ResizeMode.aspect);
| Name | Type | Description |
|---|---|---|
value? |
boolean | ResizeMode |
是否禁用调整形状大小的设置。 |
any
如果未设置值,返回是否禁用调整形状大小的设置。
▸ allowRotate(value?): any
获取或设置是否禁用旋转形状。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var state = heart.allowRotate();
heart.allowRotate(!state);
| Name | Type | Description |
|---|---|---|
value? |
boolean |
是否禁用旋转形状的设置。 |
any
如果未设置值,返回是否禁用旋转形状的设置。
▸ alt(value?): any
获取或设置形状的替代文本(用于屏幕阅读器)。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
heart.alt("一个心形");
| Name | Type | Description |
|---|---|---|
value? |
string |
形状的替代文本。 |
any
形状的替代文本。
▸ canPrint(value?): any
获取或设置此形状是否可打印。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var state = heart.canPrint(); // 获取形状是否可打印,默认值为 true.
workbook.print(); // 心形被打印。
heart.canPrint(false);
workbook.print(); // 心形不被打印。
| Name | Type | Description |
|---|---|---|
value? |
boolean |
指示此形状是否可打印的值。 |
any
如果未设置值,返回此形状是否可打印。
▸ dynamicMove(value?): any
获取或设置形状在隐藏或显示、调整大小或移动行或列时是否移动。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var state = heart.dynamicMove();
heart.dynamicMove(!state);
| Name | Type | Description |
|---|---|---|
value? |
boolean |
指示形状在隐藏或显示、调整大小或移动行或列时是否移动的值。 |
any
如果未设置值,返回此形状是否动态移动。
▸ dynamicSize(value?): any
获取或设置形状在隐藏或显示、调整大小或移动行或列时是否改变大小。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var state = heart.dynamicSize();
heart.dynamicSize(!state);
| Name | Type | Description |
|---|---|---|
value? |
boolean |
指示形状在隐藏或显示、调整大小或移动行或列时是否改变大小的值。 |
any
如果未设置值,返回此形状是否动态改变大小。
▸ endColumn(value?): any
获取或设置形状位置的结束列索引。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var n = heart.endColumn();
heart.endColumn(n + 1);
| Name | Type | Description |
|---|---|---|
value? |
number |
形状位置的结束列索引。 |
any
如果未设置值,返回形状位置的结束列索引。
▸ endColumnOffset(value?): any
获取或设置相对于形状结束列的偏移量。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var n = heart.endColumnOffset();
heart.endColumnOffset(0);
| Name | Type | Description |
|---|---|---|
value? |
number |
相对于形状结束列的偏移量。 |
any
如果未设置值,返回相对于形状结束列的偏移量。
▸ endRow(value?): any
获取或设置形状位置的结束行索引。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var n = heart.endRow();
heart.endRow(n + 2);
| Name | Type | Description |
|---|---|---|
value? |
number |
形状位置的结束行索引。 |
any
如果未设置值,返回形状位置的结束行索引。
▸ endRowOffset(value?): any
获取或设置相对于形状结束行的偏移量。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var n = heart.endRowOffset();
heart.endRowOffset(0);
| Name | Type | Description |
|---|---|---|
value? |
number |
相对于形状结束行的偏移量。 |
any
如果未设置值,返回相对于形状结束行的偏移量。
▸ getFormula(path): string
通过路径获取形状的公式字符串。
example
sheet.name("Sheet1");
sheet.setValue(0, 1, 150);
var shape1 = sheet.shapes.add("myShape1", GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 100, 100, 200, 200);
shape1.setFormula("x", "=Sheet1!B1");
shape1.getFormula("x");//returns "=Sheet1!B1"
| Name | Type | Description |
|---|---|---|
path |
string |
可以接受公式字符串的路径,可以是以下之一:"x", "y", "width", "height"。 |
string
返回通过路径获取的形状公式字符串。
▸ height(value?): any
获取或设置形状的高度。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var n = heart.height();
heart.height(n + 50);
| Name | Type | Description |
|---|---|---|
value? |
string | number |
形状的高度,可以是数值或公式(以=开头)。 |
any
如果未设置值,返回形状的高度。
▸ hyperlink(value?): void | IHyperlink
获取或设置形状的超链接。
example
var shape = sheet.shapes.add("myShape", GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 62 * 9, 0, 200, 200);
shape.hyperlink({url: "http://www.spreadjs.com", target: 0, tooltip: 'goes to SpreadJS'});
| Name | Type | Description |
|---|---|---|
value? |
IHyperlink |
超链接设置。 |
void | IHyperlink
如果未设置值,返回形状当前的超链接设置。
▸ isLocked(value?): any
获取或设置此形状是否被锁定。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var state = heart.isLocked();
heart.isLocked(!state);
| Name | Type | Description |
|---|---|---|
value? |
boolean |
指示此形状是否被锁定的值。 |
any
如果未设置值,返回此形状是否被锁定。
▸ isSelected(value?): any
获取或设置此形状是否被选中。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var state = heart.isSelected();
heart.isSelected(!state);
| Name | Type | Description |
|---|---|---|
value? |
boolean |
指示此形状是否被选中的值。 |
any
如果未设置值,返回此形状是否被选中。
▸ isVisible(value?): any
获取或设置此形状是否可见。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var state = heart.isVisible();
heart.isVisible(!state);
| Name | Type | Description |
|---|---|---|
value? |
boolean |
指示此形状是否可见的值。 |
any
如果未设置值,返回此形状是否可见。
▸ name(value?): any
获取或设置形状的名称。
example
var shape1 = sheet.shapes.add("myShape1", GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 62 * 9, 0, 200, 200);
var shape2 = sheet.shapes.add("myShape2", GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 20, 20, 200, 200);
var shape = sheet.shapes.group([shape1, shape2]);
shape.name("myGroupShape");
var shapeName = shape.name();
| Name | Type | Description |
|---|---|---|
value? |
string |
形状的名称。 |
any
如果未设置值,返回形状的名称。
▸ setFormula(path, formula): void
通过路径设置形状的公式字符串。
example
sheet.name("Sheet1");
sheet.setValue(0, 1, 150);
var shape1 = sheet.shapes.add("myShape1", GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 100, 100, 200, 200);
shape1.setFormula("x", "=Sheet1!B1");
| Name | Type | Description |
|---|---|---|
path |
string |
可以接受公式字符串的路径,可以是以下之一:"x", "y", "width", "height"。 |
formula |
string |
公式字符串。 |
void
▸ showHandle(value?): any
获取或设置是否显示形状的控制柄。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var state = heart.showHandle();
heart.showHandle(!state);
| Name | Type | Description |
|---|---|---|
value? |
boolean |
是否显示形状控制柄的设置。 |
any
如果未设置值,返回是否显示形状控制柄的设置。
▸ startColumn(value?): any
获取或设置形状位置的起始列索引。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var n = heart.startColumn();
heart.startColumn(n + 2);
| Name | Type | Description |
|---|---|---|
value? |
number |
形状位置的起始列索引。 |
any
如果未设置值,返回形状位置的起始列索引。
▸ startColumnOffset(value?): any
获取或设置相对于形状起始列的偏移量。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var n = heart.startColumnOffset();
heart.startColumnOffset(0);
| Name | Type | Description |
|---|---|---|
value? |
number |
相对于形状起始列的偏移量。 |
any
如果未设置值,返回相对于形状起始列的偏移量。
▸ startRow(value?): any
获取或设置形状位置的起始行索引。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var n = heart.startRow();
heart.startRow(n + 2);
| Name | Type | Description |
|---|---|---|
value? |
number |
形状位置的起始行索引。 |
any
如果未设置值,返回形状位置的起始行索引。
▸ startRowOffset(value?): any
获取或设置相对于形状起始行的偏移量。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var n = heart.startRowOffset();
heart.startRowOffset(0);
| Name | Type | Description |
|---|---|---|
value? |
number |
相对于形状起始行的偏移量。 |
any
如果未设置值,返回相对于形状起始行的偏移量。
▸ toImageSrc(): string
获取形状的Base64字符串类型的图片源。
example
let shapeImageSrc = sheet.shapes.all()[0].toImageSrc();
string
返回形状的Base64字符串类型的图片源。
▸ toImageSrcAsync(): Promise<string>
获取形状的Base64字符串类型的图片源。
example
let shapeImageSrc = await sheet.shapes.all()[0].toImageSrcAsync();
Promise<string>
返回形状的Base64字符串类型的图片源。
▸ width(value?): any
获取或设置形状的宽度。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var n = heart.width();
heart.width(n + 50);
| Name | Type | Description |
|---|---|---|
value? |
string | number |
形状的宽度,可以是数值或公式(以=开头)。 |
any
如果未设置值,返回形状的宽度。
▸ x(value?): any
获取或设置形状的水平位置。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var n = heart.x();
heart.x(n + 50);
| Name | Type | Description |
|---|---|---|
value? |
string | number |
形状的水平位置,可以是数值或公式(以=开头)。 |
any
如果未设置值,返回形状的水平位置。
▸ y(value?): any
获取或设置形状的垂直位置。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var n = heart.y();
heart.y(n + 50);
| Name | Type | Description |
|---|---|---|
value? |
string | number |
形状的垂直位置,可以是数值或公式(以=开头)。 |
any
如果未设置值,返回形状的垂直位置。