[]
↳ CameraShape
• new CameraShape(worksheet, name, range, left?, top?, width?, height?)
用于将工作表中指定单元格区域的内容投影为图像快照,并以独立形状对象的形式进行展示。
| Name | Type | Description |
|---|---|---|
worksheet |
Worksheet |
形状所在的宿主工作表。 |
name |
string |
照相机形状的名称。如果名称为空字符串,将自动生成唯一名称。 |
range |
string |
用于生成形状的单元格区域,需传入区域公式(例如 Sheet1!A1:A8)。 |
left? |
number |
可选参数。形状的x坐标(水平位置)。 |
top? |
number |
可选参数。形状的y坐标(垂直位置)。 |
width? |
number |
可选参数。照相机形状的宽度,留空则默认与原始单元格区域的宽度一致。 |
height? |
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
如果未设置值,返回此形状是否可打印。
▸ doubleClickCommand(value?): string | void | Function
获取或设置形状的双击命令。
example
var shape = sheet.shapes.addCameraShape("shape1", 'Sheet1!A1:A8', 100, 50, 100, 150);
shape.doubleClickCommand(null);
| Name | Type | Description |
|---|---|---|
value? |
string | Function |
双击照相机形状时执行的行为(而非跳转到源单元格区域),若为函数则不会序列化。默认命令为'openUrl'。 |
string | void | Function
未设置值时,返回形状当前的双击命令设置。
▸ 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
如果未设置值,返回形状的名称。
▸ range(value?): string | void
获取或设置照相机形状的单元格区域。
example
var shape = sheet.shapes.addCameraShape("shape1", 'Sheet1!A1:A8', 100, 50, 100, 150);
shape.range('Sheet2!A2:B8');
| Name | Type | Description |
|---|---|---|
value? |
string |
由单元格区域公式指定的照相机形状区域(如Sheet1!A1:A8)。 |
string | void
未设置值时,返回照相机形状的单元格区域。
▸ rotate(value?): number | void
获取或设置照相机形状的旋转角度(单位:度)。
example
var shape = sheet.shapes.addCameraShape("shape1", 'Sheet1!A1:A8', 100, 50, 100, 150);
var n = shape.rotate();
shape.rotate(n + 30);
| Name | Type | Description |
|---|---|---|
value? |
string | number |
旋转角度(单位:度),可通过数值或公式(以=开头,返回数值)指定。 |
number | void
未设置值时,返回照相机形状的旋转角度(单位:度)。
▸ 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
如果未设置值,返回相对于形状起始行的偏移量。
▸ style(value?): any
获取或设置照相机形状的样式。
example
// 此示例为形状设置样式。
var shape = sheet.shapes.addCameraShape("shape1", 'Sheet1!A1:A8', 100, 50, 100, 150);
var oldStyle = shape.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.transparency = 0.5;
shape.style(oldStyle);
| Name | Type | Description |
|---|---|---|
value? |
ShapeStyle |
形状样式。 |
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
如果未设置值,返回形状的垂直位置。