[]
Sheets.Shapes.FormControlShape
↳ FormControlShape
• new FormControlShape(worksheet, formControlType, left?, top?, width?, height?)
表单控件形状(FormControlShape)用于在工作表中嵌入各类表单控件,实现交互式输入和用户交互功能。
| Name | Type | Description |
|---|---|---|
worksheet |
Worksheet |
形状所在的宿主工作表。 |
formControlType |
FormControlType |
表单控件的特定类型。 |
left? |
number |
形状的x坐标(水平位置)。 |
top? |
number |
形状的y坐标(垂直位置)。 |
width? |
number |
形状的宽度。 |
height? |
number |
形状的高度。 |
▸ adjustments(arrayValue?): void | number[]
获取或设置形状的调整值。
example
var blockArc = sheet.shapes.add("", GC.Spread.Sheets.Shapes.AutoShapeType.blockArc, 100, 60, 200, 160);
var adjustments = blockArc.adjustments();
console.log(adjustments);
adjustments[0] = 150;
adjustments[1] = 15;
adjustments[2] = 0.35;
blockArc.adjustments(adjustments);
blockArc.isSelected(true);
| Name | Type | Description |
|---|---|---|
arrayValue? |
number[] |
调整值数组。 |
void | number[]
如果未设置值,返回形状当前的调整值。
▸ 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
如果未设置值,返回此形状是否动态改变大小。
▸ enabled(v?): boolean
获取或设置表单控件形状是否启用。
| Name | Type |
|---|---|
v? |
boolean |
boolean
当前启用状态。
▸ 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
如果未设置值,返回相对于形状结束行的偏移量。
▸ formControlType(): FormControlType
获取表单控件的特定类型。
表单控件类型。
▸ getFormula(path): string
通过路径获取形状的公式字符串。
example
sheet.name("Sheet1");
sheet.setValue(0, 1, "This is a rectangle.");
var shape1 = sheet.shapes.add("myShape1", GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 100, 100, 200, 200);
shape1.setFormula("text", "=Sheet1!B1");
shape1.getFormula("text");//returns "=Sheet1!B1"
| Name | Type | Description |
|---|---|---|
path |
string |
可以接受公式字符串的路径,可以是以下之一:"x", "y", "width", "height", "rotate", "text", 填充:"style.fill.color", "style.fill.transparency", 填充图片:"style.fill.src", "style.fill.tilePictureAsTexture", 填充偏移:"style.fill.offsetLeft", "style.fill.offsetRight", "style.fill.offsetTop", "style.fill.offsetBottom", 填充缩放与对齐:"style.fill.offsetX", "style.fill.offsetY", "style.fill.scaleX", "style.fill.scaleY", "style.fill.alignment", "style.fill.mirrorType", 填充类型:"style.fill.type", "style.fill.angle", "style.fill.direction", 渐变停止点:"style.fill.stops.0.color", "style.fill.stops.0.position", "style.fill.stops.0.transparency", "style.fill.stops.0.brightness", 线条:"style.line.color", "style.line.lineStyle", "style.line.width", "style.line.capType", "style.line.joinType", "style.line.compoundType", "style.line.transparency", 文本效果:"style.textEffect.color", "style.textEffect.transparency", "style.textEffect.font", 文本框:"style.textFrame.vAlign", "style.textFrame.hAlign"。 |
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
如果未设置值,返回此形状是否被选中。
▸ isTextBox(value?): boolean | void
获取或设置形状是否为文本框。
example
var rectangle = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 100, 60, 200, 160);
rectangle.isTextBox(true);
| Name | Type | Description |
|---|---|---|
value? |
boolean |
指示形状是否为文本框的值。 |
boolean | void
如果未设置值,返回形状是否为文本框。
▸ 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
如果未设置值,返回形状的名称。
▸ options(v?): IFormControlShapeOptions
获取或设置表单控件形状的选项。
| Name | Type | Description |
|---|---|---|
v? |
IFormControlShapeOptions |
表单控件形状的选项对象。 |
当前选项对象。
▸ rotate(value?): number | void
获取或设置形状的旋转角度(单位为度)。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var n = heart.rotate();
heart.rotate(n + 30);
| Name | Type | Description |
|---|---|---|
value? |
string | number |
形状的旋转角度(单位为度),可以由数字或公式(以=开头)指定,可以获取数字值。 |
number | void
如果未设置值,返回形状的旋转角度(单位为度)。
▸ setFormula(path, formula): void
通过路径设置形状的公式字符串。
example
sheet.name("Sheet1");
sheet.setValue(0, 1, "This is a rectangle.");
var shape1 = sheet.shapes.add("myShape1", GC.Spread.Sheets.Shapes.AutoShapeType.rectangle, 100, 100, 200, 200);
shape1.setFormula("text", "=Sheet1!B1");
| Name | Type | Description |
|---|---|---|
path |
string |
可以接受公式字符串的路径,可以是以下之一:"x", "y", "width", "height", "rotate", "text", 填充:"style.fill.color", "style.fill.transparency", 填充图片:"style.fill.src", "style.fill.tilePictureAsTexture", 填充偏移:"style.fill.offsetLeft", "style.fill.offsetRight", "style.fill.offsetTop", "style.fill.offsetBottom", 填充缩放与对齐:"style.fill.offsetX", "style.fill.offsetY", "style.fill.scaleX", "style.fill.scaleY", "style.fill.alignment", "style.fill.mirrorType", 填充类型:"style.fill.type", "style.fill.angle", "style.fill.direction", 渐变停止点:"style.fill.stops.0.color", "style.fill.stops.0.position", "style.fill.stops.0.transparency", "style.fill.stops.0.brightness", 线条:"style.line.color", "style.line.lineStyle", "style.line.width", "style.line.capType", "style.line.joinType", "style.line.compoundType", "style.line.transparency", 文本效果:"style.textEffect.color", "style.textEffect.transparency", "style.textEffect.font", 文本框:"style.textFrame.vAlign", "style.textFrame.hAlign"。 |
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
如果未设置值,返回相对于形状起始行的偏移量。
▸ style(value?): any
获取或设置形状的样式。
example
//此示例为形状设置样式。
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var oldStyle = heart.style();
oldStyle.fill.color = "red";
oldStyle.fill.transparency = 0.5;
oldStyle.line.color = "green";
oldStyle.line.lineStyle = GC.Spread.Sheets.Shapes.PresetLineDashStyle.dashDot;
oldStyle.line.width = 5;
oldStyle.line.capType = GC.Spread.Sheets.Shapes.LineCapStyle.square;
oldStyle.line.joinType = GC.Spread.Sheets.Shapes.LineJoinStyle.miter;
oldStyle.line.compoundType = GC.Spread.Sheets.Shapes.CompoundType.double;
oldStyle.line.transparency = 0.5;
oldStyle.textEffect.color = "yellow";
oldStyle.textEffect.transparency = 0.5;
oldStyle.textEffect.font = "20px Arial";
oldStyle.textFrame.vAlign = GC.Spread.Sheets.VerticalAlign.center;
oldStyle.textFrame.hAlign = GC.Spread.Sheets.HorizontalAlign.center;
heart.style(oldStyle);
heart.text("Heart");
| Name | Type | Description |
|---|---|---|
value? |
ShapeStyle |
形状样式。 |
any
如果未设置值,返回形状当前的样式。
▸ text(value?): any
获取或设置形状的文本。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
heart.text("My Shape");
var s = heart.text();
| Name | Type | Description |
|---|---|---|
value? |
string |
形状的文本,可以由字符串或公式(以=开头)指定,可以获取字符串。 |
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字符串类型的图片源。
▸ type(value?): any
获取或设置形状的类型。
example
var heart = sheet.shapes.add("Shape1", GC.Spread.Sheets.Shapes.AutoShapeType.heart, 100, 60, 200, 160);
var n = heart.type();
heart.type(GC.Spread.Sheets.Shapes.AutoShapeType.cloud);
| Name | Type | Description |
|---|---|---|
value? |
AutoShapeType |
形状的类型。 |
any
如果未设置值,则返回形状的类型。
▸ value(v?): IFormControlShapeValue
获取或设置表单控件形状的值。
| Name | Type | Description |
|---|---|---|
v? |
IFormControlShapeValue |
表单控件形状的值对象。 |
当前值对象。
▸ 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
如果未设置值,返回形状的垂直位置。