Excel.Shape class

代表工作表中的一个通用 shape 对象。Represents a generic shape object in the worksheet. 一个形状可以是一个几何形状、一条线、一组形状, 等等。A shape could be a geometric shape, a line, a group of shapes, etc.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

Extends

属性

altTextDescription

返回或设置形状对象的可选说明文本。Returns or sets the alternative description text for a Shape object.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

altTextTitle

返回或设置形状对象的可选标题文本。Returns or sets the alternative title text for a Shape object.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

connectionSiteCount

返回此形状上的连接站点数。Returns the number of connection sites on this shape. 只读。Read-only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

context

与该对象关联的请求上下文。The request context associated with the object. 这会将加载项的进程连接到 Office 主机应用程序的进程。This connects the add-in's process to the Office host application's process.

fill

返回此形状的填充格式。Returns the fill formatting of this shape. 只读。Read-only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

geometricShape

返回与形状关联的几何形状。Returns the geometric shape associated with the shape. 如果形状类型不是“GeometricShape”,则会引发错误。An error will be thrown if the shape type is not "GeometricShape".

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

geometricShapeType

表示此几何形状的几何形状类型。Represents the geometric shape type of this geometric shape. 有关详细信息,请参阅 Excel.GeometricShapeType。See Excel.GeometricShapeType for details. 如果形状类型不是“GeometricShape”,返回 NULL。Returns null if the shape type is not "GeometricShape".

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

group

返回与形状关联的形状组。Returns the shape group associated with the shape. 如果形状类型不是“GroupShape”,则会引发错误。An error will be thrown if the shape type is not "GroupShape".

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

height

表示形状的高度(以磅为单位)。Represents the height, in points, of the shape. 当设置为负值或零作为输入时, 将引发无效参数异常。Throws an invalid argument exception when set with a negative value or zero as input.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

id

表示形状标识符。Represents the shape identifier. 只读。Read-only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

image

返回与形状关联的图像。Returns the image associated with the shape. 如果形状类型不是“Image”,则会引发错误。An error will be thrown if the shape type is not "Image".

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

left

从形状左侧到工作表左侧的距离(以磅为单位)。The distance, in points, from the left side of the shape to the left side of the worksheet. 当设置为负值作为输入时, 将引发无效参数异常。Throws an invalid argument exception when set with a negative value as input.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

level

表示指定形状的级别。Represents the level of the specified shape. 例如,级别 0 表示形状不是任何组的一部分,级别 1 表示形状是顶级组的一部分,级别 2 表示形状是顶级子组的一部分。For example, a level of 0 means that the shape is not part of any groups, a level of 1 means the shape is part of a top-level group, and a level of 2 means the shape is part of a sub-group of the top level.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

line

返回与形状关联的线条。Returns the line associated with the shape. 如果形状类型不是“Line”,则会引发错误。An error will be thrown if the shape type is not "Line".

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

lineFormat

返回此形状的线条格式。Returns the line formatting of this shape. 只读。Read-only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

lockAspectRatio

指定此形状的纵横比是否锁定。Specifies whether or not the aspect ratio of this shape is locked.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

name

表示形状的名称。Represents the name of the shape.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

parentGroup

表示此形状的父组。Represents the parent group of this shape.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

placement

表示对象如何附加到其下方的单元格。Represents how the object is attached to the cells below it.

[API 集: EXCELAPI BETA (仅限预览)][ API set: ExcelApi BETA (PREVIEW ONLY) ]

rotation

表示形状的旋转度数。Represents the rotation, in degrees, of the shape.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

textFrame

返回此形状的文本框对象。Returns the text frame object of this shape. 只读。Read only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

top

从形状上边缘到工作表上边缘之间的距离(以磅为单位)。The distance, in points, from the top edge of the shape to the top edge of the worksheet. 当设置为负值作为输入时, 将引发无效参数异常。Throws an invalid argument exception when set with a negative value as input.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

type

返回此形状的类型。Returns the type of this shape. 有关详细信息,请参阅 Excel.ShapeType。See Excel.ShapeType for details. 只读。Read-only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

visible

表示此形状的可视性。Represents the visibility of this shape.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

width

表示形状的宽度(以磅为单位)。Represents the width, in points, of the shape. 当设置为负值或零作为输入时, 将引发无效参数异常。Throws an invalid argument exception when set with a negative value or zero as input.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

zOrderPosition

返回指定形状在 z 顺序中的位置,0 表示顺序堆栈的底部。Returns the position of the specified shape in the z-order, with 0 representing the bottom of the order stack. 只读。Read-only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

方法

copyTo(destinationSheet)

复制并粘贴 Shape 对象。Copies and pastes a Shape object. 粘贴的形状将复制到与此形状相同的像素位置。The pasted shape is copied to the same pixel location as this shape.

[API 集: EXCELAPI BETA (仅限预览)][ API set: ExcelApi BETA (PREVIEW ONLY) ]

delete()

从工作表删除形状。Removes the shape from the worksheet.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

getAsImage(format)

将形状转换为图像并将图像返回为 base64 编码字符串。Converts the shape to an image and returns the image as a base64-encoded string. DPI 为 96。The DPI is 96. 唯一受支持的格式是Excel.PictureFormat.BMPThe only supported formats are Excel.PictureFormat.BMP, Excel.PictureFormat.PNG, Excel.PictureFormat.JPEG, 并Excel.PictureFormat.GIF, and Excel.PictureFormat.GIF.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

getAsImage(formatString)

将形状转换为图像并将图像返回为 base64 编码字符串。Converts the shape to an image and returns the image as a base64-encoded string. DPI 为 96。The DPI is 96. 唯一受支持的格式是Excel.PictureFormat.BMPThe only supported formats are Excel.PictureFormat.BMP, Excel.PictureFormat.PNG, Excel.PictureFormat.JPEG, 并Excel.PictureFormat.GIF, and Excel.PictureFormat.GIF.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

incrementLeft(increment)

以指定磅数水平移动形状。Moves the shape horizontally by the specified number of points.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

incrementRotation(increment)

将形状围绕 z 轴旋转特定度数。Rotates the shape clockwise around the z-axis by the specified number of degrees. 使用rotation属性可设置形状的绝对旋转量。Use the rotation property to set the absolute rotation of the shape.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

incrementTop(increment)

以指定磅数垂直移动形状。Moves the shape vertically by the specified number of points.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

load(option)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性之前,你必须调用“context.sync()”。You must call "context.sync()" before reading the properties.

load(propertyNames)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性context.sync()之前, 必须先调用。You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性context.sync()之前, 必须先调用。You must call context.sync() before reading the properties.

scaleHeight(scaleFactor, scaleType, scaleFrom)

按指定因子缩放形状的高度。Scales the height of the shape by a specified factor. 对于图像,你可以说明是相对于原始尺寸还是当前尺寸缩放形状。For images, you can indicate whether you want to scale the shape relative to the original or the current size. 对于除图片以外的其他形状来说,缩放总是相对于其当前高度而言。Shapes other than pictures are always scaled relative to their current height.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

scaleHeight(scaleFactor, scaleTypeString, scaleFrom)

按指定因子缩放形状的高度。Scales the height of the shape by a specified factor. 对于图像,你可以说明是相对于原始尺寸还是当前尺寸缩放形状。For images, you can indicate whether you want to scale the shape relative to the original or the current size. 对于除图片以外的其他形状来说,缩放总是相对于其当前高度而言。Shapes other than pictures are always scaled relative to their current height.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

scaleWidth(scaleFactor, scaleType, scaleFrom)

按指定因子缩放形状的宽度。Scales the width of the shape by a specified factor. 对于图像,你可以说明是相对于原始尺寸还是当前尺寸缩放形状。For images, you can indicate whether you want to scale the shape relative to the original or the current size. 对于除图片以外的其他形状来说,缩放总是相对于其当前宽度而言。Shapes other than pictures are always scaled relative to their current width.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

scaleWidth(scaleFactor, scaleTypeString, scaleFrom)

按指定因子缩放形状的宽度。Scales the width of the shape by a specified factor. 对于图像,你可以说明是相对于原始尺寸还是当前尺寸缩放形状。For images, you can indicate whether you want to scale the shape relative to the original or the current size. 对于除图片以外的其他形状来说,缩放总是相对于其当前宽度而言。Shapes other than pictures are always scaled relative to their current width.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

set(properties, options)

同时设置一个对象的多个属性。Sets multiple properties of an object at the same time. 您可以传递具有相应属性的纯对象或相同类型的其他 API 对象。You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties)

基于现有加载的对象同时设置该对象的多个属性。Sets multiple properties on the object at the same time, based on an existing loaded object.

setZOrder(position)

将指定形状沿集合的 z 顺序向上或向下移动,将其移动到其他形状的前面或后面。Moves the specified shape up or down the collection's z-order, which shifts it in front of or behind other shapes.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

setZOrder(positionString)

将指定形状沿集合的 z 顺序向上或向下移动,将其移动到其他形状的前面或后面。Moves the specified shape up or down the collection's z-order, which shifts it in front of or behind other shapes.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

toJSON()

重写 JavaScript toJSON()方法, 以便在将 API 对象传递到时提供更有用的输出JSON.stringify()Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify反过来, 也会调用传递toJSON给它的对象的方法。尽管原始的 Excel. Shape 对象是 API 对象, 但toJSON方法返回一个简单的 JavaScript 对象 (类型为Excel.Interfaces.ShapeData, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.Shape object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.ShapeData), 其中包含原始对象中所有已加载的子属性的浅表副本。) that contains shallow copies of any loaded child properties from the original object.

事件

onActivated

当激活形状时发生此事件。Occurs when the shape is activated.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

onDeactivated

当停用形状时发生此事件。Occurs when the shape is deactivated.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

属性详细信息

altTextDescription

返回或设置形状对象的可选说明文本。Returns or sets the alternative description text for a Shape object.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

altTextDescription: string;

属性值

string

altTextTitle

返回或设置形状对象的可选标题文本。Returns or sets the alternative title text for a Shape object.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

altTextTitle: string;

属性值

string

connectionSiteCount

返回此形状上的连接站点数。Returns the number of connection sites on this shape. 只读。Read-only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly connectionSiteCount: number;

属性值

number

context

与该对象关联的请求上下文。The request context associated with the object. 这会将加载项的进程连接到 Office 主机应用程序的进程。This connects the add-in's process to the Office host application's process.

context: RequestContext;

属性值

RequestContext

fill

返回此形状的填充格式。Returns the fill formatting of this shape. 只读。Read-only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly fill: Excel.ShapeFill;

属性值

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Shapes");
    const shape = sheet.shapes.addGeometricShape(Excel.GeometricShapeType.smileyFace);
    shape.left = 300;
    shape.top = 100;
    shape.height = 100;
    shape.width = 100;
    shape.fill.foregroundColor = "yellow"
    await context.sync();
});

geometricShape

返回与形状关联的几何形状。Returns the geometric shape associated with the shape. 如果形状类型不是“GeometricShape”,则会引发错误。An error will be thrown if the shape type is not "GeometricShape".

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly geometricShape: Excel.GeometricShape;

属性值

geometricShapeType

表示此几何形状的几何形状类型。Represents the geometric shape type of this geometric shape. 有关详细信息,请参阅 Excel.GeometricShapeType。See Excel.GeometricShapeType for details. 如果形状类型不是“GeometricShape”,返回 NULL。Returns null if the shape type is not "GeometricShape".

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

geometricShapeType: Excel.GeometricShapeType | "LineInverse" | "Triangle" | "RightTriangle" | "Rectangle" | "Diamond" | "Parallelogram" | "Trapezoid" | "NonIsoscelesTrapezoid" | "Pentagon" | "Hexagon" | "Heptagon" | "Octagon" | "Decagon" | "Dodecagon" | "Star4" | "Star5" | "Star6" | "Star7" | "Star8" | "Star10" | "Star12" | "Star16" | "Star24" | "Star32" | "RoundRectangle" | "Round1Rectangle" | "Round2SameRectangle" | "Round2DiagonalRectangle" | "SnipRoundRectangle" | "Snip1Rectangle" | "Snip2SameRectangle" | "Snip2DiagonalRectangle" | "Plaque" | "Ellipse" | "Teardrop" | "HomePlate" | "Chevron" | "PieWedge" | "Pie" | "BlockArc" | "Donut" | "NoSmoking" | "RightArrow" | "LeftArrow" | "UpArrow" | "DownArrow" | "StripedRightArrow" | "NotchedRightArrow" | "BentUpArrow" | "LeftRightArrow" | "UpDownArrow" | "LeftUpArrow" | "LeftRightUpArrow" | "QuadArrow" | "LeftArrowCallout" | "RightArrowCallout" | "UpArrowCallout" | "DownArrowCallout" | "LeftRightArrowCallout" | "UpDownArrowCallout" | "QuadArrowCallout" | "BentArrow" | "UturnArrow" | "CircularArrow" | "LeftCircularArrow" | "LeftRightCircularArrow" | "CurvedRightArrow" | "CurvedLeftArrow" | "CurvedUpArrow" | "CurvedDownArrow" | "SwooshArrow" | "Cube" | "Can" | "LightningBolt" | "Heart" | "Sun" | "Moon" | "SmileyFace" | "IrregularSeal1" | "IrregularSeal2" | "FoldedCorner" | "Bevel" | "Frame" | "HalfFrame" | "Corner" | "DiagonalStripe" | "Chord" | "Arc" | "LeftBracket" | "RightBracket" | "LeftBrace" | "RightBrace" | "BracketPair" | "BracePair" | "Callout1" | "Callout2" | "Callout3" | "AccentCallout1" | "AccentCallout2" | "AccentCallout3" | "BorderCallout1" | "BorderCallout2" | "BorderCallout3" | "AccentBorderCallout1" | "AccentBorderCallout2" | "AccentBorderCallout3" | "WedgeRectCallout" | "WedgeRRectCallout" | "WedgeEllipseCallout" | "CloudCallout" | "Cloud" | "Ribbon" | "Ribbon2" | "EllipseRibbon" | "EllipseRibbon2" | "LeftRightRibbon" | "VerticalScroll" | "HorizontalScroll" | "Wave" | "DoubleWave" | "Plus" | "FlowChartProcess" | "FlowChartDecision" | "FlowChartInputOutput" | "FlowChartPredefinedProcess" | "FlowChartInternalStorage" | "FlowChartDocument" | "FlowChartMultidocument" | "FlowChartTerminator" | "FlowChartPreparation" | "FlowChartManualInput" | "FlowChartManualOperation" | "FlowChartConnector" | "FlowChartPunchedCard" | "FlowChartPunchedTape" | "FlowChartSummingJunction" | "FlowChartOr" | "FlowChartCollate" | "FlowChartSort" | "FlowChartExtract" | "FlowChartMerge" | "FlowChartOfflineStorage" | "FlowChartOnlineStorage" | "FlowChartMagneticTape" | "FlowChartMagneticDisk" | "FlowChartMagneticDrum" | "FlowChartDisplay" | "FlowChartDelay" | "FlowChartAlternateProcess" | "FlowChartOffpageConnector" | "ActionButtonBlank" | "ActionButtonHome" | "ActionButtonHelp" | "ActionButtonInformation" | "ActionButtonForwardNext" | "ActionButtonBackPrevious" | "ActionButtonEnd" | "ActionButtonBeginning" | "ActionButtonReturn" | "ActionButtonDocument" | "ActionButtonSound" | "ActionButtonMovie" | "Gear6" | "Gear9" | "Funnel" | "MathPlus" | "MathMinus" | "MathMultiply" | "MathDivide" | "MathEqual" | "MathNotEqual" | "CornerTabs" | "SquareTabs" | "PlaqueTabs" | "ChartX" | "ChartStar" | "ChartPlus";

属性值

Excel.GeometricShapeType | "LineInverse" | "Triangle" | "RightTriangle" | "Rectangle" | "Diamond" | "Parallelogram" | "Trapezoid" | "NonIsoscelesTrapezoid" | "Pentagon" | "Hexagon" | "Heptagon" | "Octagon" | "Decagon" | "Dodecagon" | "Star4" | "Star5" | "Star6" | "Star7" | "Star8" | "Star10" | "Star12" | "Star16" | "Star24" | "Star32" | "RoundRectangle" | "Round1Rectangle" | "Round2SameRectangle" | "Round2DiagonalRectangle" | "SnipRoundRectangle" | "Snip1Rectangle" | "Snip2SameRectangle" | "Snip2DiagonalRectangle" | "Plaque" | "Ellipse" | "Teardrop" | "HomePlate" | "Chevron" | "PieWedge" | "Pie" | "BlockArc" | "Donut" | "NoSmoking" | "RightArrow" | "LeftArrow" | "UpArrow" | "DownArrow" | "StripedRightArrow" | "NotchedRightArrow" | "BentUpArrow" | "LeftRightArrow" | "UpDownArrow" | "LeftUpArrow" | "LeftRightUpArrow" | "QuadArrow" | "LeftArrowCallout" | "RightArrowCallout" | "UpArrowCallout" | "DownArrowCallout" | "LeftRightArrowCallout" | "UpDownArrowCallout" | "QuadArrowCallout" | "BentArrow" | "UturnArrow" | "CircularArrow" | "LeftCircularArrow" | "LeftRightCircularArrow" | "CurvedRightArrow" | "CurvedLeftArrow" | "CurvedUpArrow" | "CurvedDownArrow" | "SwooshArrow" | "Cube" | "Can" | "LightningBolt" | "Heart" | "Sun" | "Moon" | "SmileyFace" | "IrregularSeal1" | "IrregularSeal2" | "FoldedCorner" | "Bevel" | "Frame" | "HalfFrame" | "Corner" | "DiagonalStripe" | "Chord" | "Arc" | "LeftBracket" | "RightBracket" | "LeftBrace" | "RightBrace" | "BracketPair" | "BracePair" | "Callout1" | "Callout2" | "Callout3" | "AccentCallout1" | "AccentCallout2" | "AccentCallout3" | "BorderCallout1" | "BorderCallout2" | "BorderCallout3" | "AccentBorderCallout1" | "AccentBorderCallout2" | "AccentBorderCallout3" | "WedgeRectCallout" | "WedgeRRectCallout" | "WedgeEllipseCallout" | "CloudCallout" | "Cloud" | "Ribbon" | "Ribbon2" | "EllipseRibbon" | "EllipseRibbon2" | "LeftRightRibbon" | "VerticalScroll" | "HorizontalScroll" | "Wave" | "DoubleWave" | "Plus" | "FlowChartProcess" | "FlowChartDecision" | "FlowChartInputOutput" | "FlowChartPredefinedProcess" | "FlowChartInternalStorage" | "FlowChartDocument" | "FlowChartMultidocument" | "FlowChartTerminator" | "FlowChartPreparation" | "FlowChartManualInput" | "FlowChartManualOperation" | "FlowChartConnector" | "FlowChartPunchedCard" | "FlowChartPunchedTape" | "FlowChartSummingJunction" | "FlowChartOr" | "FlowChartCollate" | "FlowChartSort" | "FlowChartExtract" | "FlowChartMerge" | "FlowChartOfflineStorage" | "FlowChartOnlineStorage" | "FlowChartMagneticTape" | "FlowChartMagneticDisk" | "FlowChartMagneticDrum" | "FlowChartDisplay" | "FlowChartDelay" | "FlowChartAlternateProcess" | "FlowChartOffpageConnector" | "ActionButtonBlank" | "ActionButtonHome" | "ActionButtonHelp" | "ActionButtonInformation" | "ActionButtonForwardNext" | "ActionButtonBackPrevious" | "ActionButtonEnd" | "ActionButtonBeginning" | "ActionButtonReturn" | "ActionButtonDocument" | "ActionButtonSound" | "ActionButtonMovie" | "Gear6" | "Gear9" | "Funnel" | "MathPlus" | "MathMinus" | "MathMultiply" | "MathDivide" | "MathEqual" | "MathNotEqual" | "CornerTabs" | "SquareTabs" | "PlaqueTabs" | "ChartX" | "ChartStar" | "ChartPlus"

group

返回与形状关联的形状组。Returns the shape group associated with the shape. 如果形状类型不是“GroupShape”,则会引发错误。An error will be thrown if the shape type is not "GroupShape".

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly group: Excel.ShapeGroup;

属性值

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Shapes");

    const shapeGroup = sheet.shapes.getItem("Group").group;
    shapeGroup.ungroup();
    console.log("Shapes ungrouped");

    await context.sync();
});

height

表示形状的高度(以磅为单位)。Represents the height, in points, of the shape. 当设置为负值或零作为输入时, 将引发无效参数异常。Throws an invalid argument exception when set with a negative value or zero as input.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

height: number;

属性值

number

id

表示形状标识符。Represents the shape identifier. 只读。Read-only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly id: string;

属性值

string

image

返回与形状关联的图像。Returns the image associated with the shape. 如果形状类型不是“Image”,则会引发错误。An error will be thrown if the shape type is not "Image".

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly image: Excel.Image;

属性值

left

从形状左侧到工作表左侧的距离(以磅为单位)。The distance, in points, from the left side of the shape to the left side of the worksheet. 当设置为负值作为输入时, 将引发无效参数异常。Throws an invalid argument exception when set with a negative value as input.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

left: number;

属性值

number

level

表示指定形状的级别。Represents the level of the specified shape. 例如,级别 0 表示形状不是任何组的一部分,级别 1 表示形状是顶级组的一部分,级别 2 表示形状是顶级子组的一部分。For example, a level of 0 means that the shape is not part of any groups, a level of 1 means the shape is part of a top-level group, and a level of 2 means the shape is part of a sub-group of the top level.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly level: number;

属性值

number

line

返回与形状关联的线条。Returns the line associated with the shape. 如果形状类型不是“Line”,则会引发错误。An error will be thrown if the shape type is not "Line".

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly line: Excel.Line;

属性值

示例Examples

await Excel.run(async (context) => {
    const shapes = context.workbook.worksheets.getItem("Shapes").shapes;
    const line = shapes.getItem("StraightLine").line;
    line.beginArrowheadLength = Excel.ArrowheadLength.long;
    line.beginArrowheadWidth = Excel.ArrowheadWidth.wide;
    line.beginArrowheadStyle = Excel.ArrowheadStyle.oval;

    line.endArrowheadLength = Excel.ArrowheadLength.long;
    line.endArrowheadWidth = Excel.ArrowheadWidth.wide;
    line.endArrowheadStyle = Excel.ArrowheadStyle.triangle;

    await context.sync();
});

lineFormat

返回此形状的线条格式。Returns the line formatting of this shape. 只读。Read-only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly lineFormat: Excel.ShapeLineFormat;

属性值

lockAspectRatio

指定此形状的纵横比是否锁定。Specifies whether or not the aspect ratio of this shape is locked.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

lockAspectRatio: boolean;

属性值

boolean

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Shapes");
    const shape = sheet.shapes.getItem("Octagon")
    shape.lockAspectRatio = true;
    shape.scaleHeight(1.25, Excel.ShapeScaleType.currentSize);
    await context.sync();
});

name

表示形状的名称。Represents the name of the shape.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

name: string;

属性值

string

parentGroup

表示此形状的父组。Represents the parent group of this shape.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly parentGroup: Excel.Shape;

属性值

placement

备注

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

表示对象如何附加到其下方的单元格。Represents how the object is attached to the cells below it.

[API 集: EXCELAPI BETA (仅限预览)][ API set: ExcelApi BETA (PREVIEW ONLY) ]

placement: Excel.Placement | "TwoCell" | "OneCell" | "Absolute";

属性值

Excel.Placement | "TwoCell" | "OneCell" | "Absolute"

rotation

表示形状的旋转度数。Represents the rotation, in degrees, of the shape.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

rotation: number;

属性值

number

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Shapes");
    const shape = sheet.shapes.addGeometricShape(Excel.GeometricShapeType.triangle);
    shape.left = 100;
    shape.top = 300;
    shape.height = 150;
    shape.width = 200;
    shape.rotation = 45;
    shape.fill.clear();
    await context.sync();
});

textFrame

返回此形状的文本框对象。Returns the text frame object of this shape. 只读。Read only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly textFrame: Excel.TextFrame;

属性值

top

从形状上边缘到工作表上边缘之间的距离(以磅为单位)。The distance, in points, from the top edge of the shape to the top edge of the worksheet. 当设置为负值作为输入时, 将引发无效参数异常。Throws an invalid argument exception when set with a negative value as input.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

top: number;

属性值

number

type

返回此形状的类型。Returns the type of this shape. 有关详细信息,请参阅 Excel.ShapeType。See Excel.ShapeType for details. 只读。Read-only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly type: Excel.ShapeType | "Unsupported" | "Image" | "GeometricShape" | "Group" | "Line";

属性值

Excel.ShapeType | "Unsupported" | "Image" | "GeometricShape" | "Group" | "Line"

visible

表示此形状的可视性。Represents the visibility of this shape.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

visible: boolean;

属性值

boolean

width

表示形状的宽度(以磅为单位)。Represents the width, in points, of the shape. 当设置为负值或零作为输入时, 将引发无效参数异常。Throws an invalid argument exception when set with a negative value or zero as input.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

width: number;

属性值

number

zOrderPosition

返回指定形状在 z 顺序中的位置,0 表示顺序堆栈的底部。Returns the position of the specified shape in the z-order, with 0 representing the bottom of the order stack. 只读。Read-only.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly zOrderPosition: number;

属性值

number

方法详细信息

copyTo(destinationSheet)

备注

此 API 以预览状态提供给开发者,可能根据我们收到的反馈更改。 请勿在生产环境中使用此 API。

复制并粘贴 Shape 对象。Copies and pastes a Shape object. 粘贴的形状将复制到与此形状相同的像素位置。The pasted shape is copied to the same pixel location as this shape.

[API 集: EXCELAPI BETA (仅限预览)][ API set: ExcelApi BETA (PREVIEW ONLY) ]

copyTo(destinationSheet?: Worksheet | string): Excel.Shape;

参数

destinationSheet
Worksheet | string

形状对象将粘贴到的工作表。The sheet to which the shape object will be pasted. 默认值是复制的形状的工作表。The default value is the copied Shape's worksheet.

返回

delete()

从工作表删除形状。Removes the shape from the worksheet.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

delete(): void;

返回

void

示例Examples

await Excel.run(async (context) => {
    context.workbook.worksheets.getItemOrNullObject("Shapes").delete();
    const sheet = context.workbook.worksheets.add("Shapes");

    const shapes = sheet.shapes;

    // load all the shapes in the collection without loading their properties
    shapes.load("items/$none");
    await context.sync();

    shapes.items.forEach((shape) => shape.delete());
    await context.sync();
});

getAsImage(format)

将形状转换为图像并将图像返回为 base64 编码字符串。Converts the shape to an image and returns the image as a base64-encoded string. DPI 为 96。The DPI is 96. 唯一受支持的格式是Excel.PictureFormat.BMPThe only supported formats are Excel.PictureFormat.BMP, Excel.PictureFormat.PNG, Excel.PictureFormat.JPEG, 并Excel.PictureFormat.GIF, and Excel.PictureFormat.GIF.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

getAsImage(format: Excel.PictureFormat): OfficeExtension.ClientResult<string>;

参数

format
Excel.PictureFormat

指定图像的格式。Specifies the format of the image.

返回

OfficeExtension.ClientResult<string>

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Shapes");
    const shape = sheet.shapes.getItem("Image");
    const result = shape.getAsImage(Excel.PictureFormat.png);
    await context.sync();

    const imageString = result.value;
    // Your add-in would save this string as a .png file.
    console.log("The image's base64-encoded string: " + imageString);
});

getAsImage(formatString)

将形状转换为图像并将图像返回为 base64 编码字符串。Converts the shape to an image and returns the image as a base64-encoded string. DPI 为 96。The DPI is 96. 唯一受支持的格式是Excel.PictureFormat.BMPThe only supported formats are Excel.PictureFormat.BMP, Excel.PictureFormat.PNG, Excel.PictureFormat.JPEG, 并Excel.PictureFormat.GIF, and Excel.PictureFormat.GIF.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

getAsImage(formatString: "UNKNOWN" | "BMP" | "JPEG" | "GIF" | "PNG" | "SVG"): OfficeExtension.ClientResult<string>;

参数

formatString
"UNKNOWN" | "BMP" | "JPEG" | "GIF" | "PNG" | "SVG"

指定图像的格式。Specifies the format of the image.

返回

OfficeExtension.ClientResult<string>

incrementLeft(increment)

以指定磅数水平移动形状。Moves the shape horizontally by the specified number of points.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

incrementLeft(increment: number): void;

参数

increment
number

以磅为单位的增量, 形状将水平移动。The increment, in points, the shape will be horizontally moved. 正值表示将形状向右移动, 值为负值时将形状向左移动。A positive value moves the shape to the right and a negative value moves it to the left. 如果工作表是从右到左方向的, 则将其反转: 正值将形状向左移动, 负值表示将形状向右移动。If the sheet is right-to-left oriented, this is reversed: positive values will move the shape to the left and negative values will move it to the right.

返回

void

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Shapes");
    const shape = sheet.shapes.getItem("Square")
    shape.incrementLeft(-25);
    await context.sync();
});

incrementRotation(increment)

将形状围绕 z 轴旋转特定度数。Rotates the shape clockwise around the z-axis by the specified number of degrees. 使用rotation属性可设置形状的绝对旋转量。Use the rotation property to set the absolute rotation of the shape.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

incrementRotation(increment: number): void;

参数

increment
number

形状将旋转多少度。How many degrees the shape will be rotated. 为正值时顺时针旋转形状,为负值时逆时针旋转形状。A positive value rotates the shape clockwise; a negative value rotates it counterclockwise.

返回

void

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Shapes");
    const shape = sheet.shapes.getItem("Image");
    shape.incrementRotation(180);
    await context.sync();
});

incrementTop(increment)

以指定磅数垂直移动形状。Moves the shape vertically by the specified number of points.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

incrementTop(increment: number): void;

参数

increment
number

以磅为单位的增量, 形状将垂直移动。The increment, in points, the shape will be vertically moved. 以磅为单位。in points. 正值表示将形状向下移动, 负值表示将形状上移。A positive value moves the shape down and a negative value moves it up.

返回

void

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Shapes");
    const shape = sheet.shapes.getItem("Pentagon")
    shape.incrementTop(25);
    await context.sync();
});

load(option)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性之前,你必须调用“context.sync()”。You must call "context.sync()" before reading the properties.

load(option?: Excel.Interfaces.ShapeLoadOptions): Excel.Shape;

参数

返回

注解

除了此签名之外, 此方法还具有以下签名:In addition to this signature, this method has the following signatures:

load(option?: string | string[]): Excel.Shape-Where 选项是一个逗号分隔的字符串或一个字符串数组, 用于指定要加载的属性。load(option?: string | string[]): Excel.Shape - Where option is a comma-delimited string or an array of strings that specify the properties to load.

load(option?: { select?: string; expand?: string; }): Excel.Shape-Where 选项。选择是一个用逗号分隔的字符串, 用于指定要加载的属性和选项。 expand 是一个用逗号分隔的字符串, 用于指定要加载的导航属性。load(option?: { select?: string; expand?: string; }): Excel.Shape - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load.

load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.Shape-仅适用于集合类型。load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.Shape - Only available on collection types. 它类似于前面的签名。It is similar to the preceding signature. Top 指定结果中可包含的集合项的最大数量。Option.top specifies the maximum number of collection items that can be included in the result. 选项。 skip 指定要跳过且不包含在结果中的项目数。Option.skip specifies the number of items that are to be skipped and not included in the result. 如果指定了 top 选项, 则在跳过指定数目的项目后将启动结果集。If option.top is specified, the result set will start after skipping the specified number of items.

load(propertyNames)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性context.sync()之前, 必须先调用。You must call context.sync() before reading the properties.

load(propertyNames?: string | string[]): Excel.Shape;

参数

propertyNames
string | string[]

一个以逗号分隔的字符串或字符串数组, 用于指定要加载的属性。A comma-delimited string or an array of strings that specify the properties to load.

返回

load(propertyNamesAndPaths)

将命令加入队列以加载对象的指定属性。Queues up a command to load the specified properties of the object. 在读取属性context.sync()之前, 必须先调用。You must call context.sync() before reading the properties.

load(propertyNamesAndPaths?: { select?: string; expand?: string; }): Excel.Shape;

参数

propertyNamesAndPaths
{ select?: string; expand?: string; }

其中, propertyNamesAndPaths 是用逗号分隔的字符串, 用于指定要加载的属性和 propertyNamesAndPaths。扩展是一个用逗号分隔的字符串, 用于指定要加载的导航属性。Where propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.

返回

scaleHeight(scaleFactor, scaleType, scaleFrom)

按指定因子缩放形状的高度。Scales the height of the shape by a specified factor. 对于图像,你可以说明是相对于原始尺寸还是当前尺寸缩放形状。For images, you can indicate whether you want to scale the shape relative to the original or the current size. 对于除图片以外的其他形状来说,缩放总是相对于其当前高度而言。Shapes other than pictures are always scaled relative to their current height.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

scaleHeight(scaleFactor: number, scaleType: Excel.ShapeScaleType, scaleFrom?: Excel.ShapeScaleFrom): void;

参数

scaleFactor
number

指定形状调整后的高度与当前或原始高度的比例。Specifies the ratio between the height of the shape after you resize it and the current or original height.

scaleType
Excel.ShapeScaleType

指定是相对于形状的原始尺寸还是当前尺寸来对其进行缩放。Specifies whether the shape is scaled relative to its original or current size. 原始大小缩放选项仅适用于图像。The original size scaling option only works for images.

scaleFrom
Excel.ShapeScaleFrom

可选。Optional. 指定在缩放形状时,该形状的哪一部分将保持在原有的位置。Specifies which part of the shape retains its position when the shape is scaled. 如果省略, 则表示形状的左上角将保留其位置。If omitted, it represents the shape's upper left corner retains its position.

返回

void

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Shapes");
    const shape = sheet.shapes.getItem("Octagon")
    shape.lockAspectRatio = true;
    shape.scaleHeight(1.25, Excel.ShapeScaleType.currentSize);
    await context.sync();
});

scaleHeight(scaleFactor, scaleTypeString, scaleFrom)

按指定因子缩放形状的高度。Scales the height of the shape by a specified factor. 对于图像,你可以说明是相对于原始尺寸还是当前尺寸缩放形状。For images, you can indicate whether you want to scale the shape relative to the original or the current size. 对于除图片以外的其他形状来说,缩放总是相对于其当前高度而言。Shapes other than pictures are always scaled relative to their current height.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

scaleHeight(scaleFactor: number, scaleTypeString: "CurrentSize" | "OriginalSize", scaleFrom?: "ScaleFromTopLeft" | "ScaleFromMiddle" | "ScaleFromBottomRight"): void;

参数

scaleFactor
number

指定形状调整后的高度与当前或原始高度的比例。Specifies the ratio between the height of the shape after you resize it and the current or original height.

scaleTypeString
"CurrentSize" | "OriginalSize"

指定是相对于形状的原始尺寸还是当前尺寸来对其进行缩放。Specifies whether the shape is scaled relative to its original or current size. 原始大小缩放选项仅适用于图像。The original size scaling option only works for images.

scaleFrom
"ScaleFromTopLeft" | "ScaleFromMiddle" | "ScaleFromBottomRight"

可选。Optional. 指定在缩放形状时,该形状的哪一部分将保持在原有的位置。Specifies which part of the shape retains its position when the shape is scaled. 如果省略, 则表示形状的左上角将保留其位置。If omitted, it represents the shape's upper left corner retains its position.

返回

void

scaleWidth(scaleFactor, scaleType, scaleFrom)

按指定因子缩放形状的宽度。Scales the width of the shape by a specified factor. 对于图像,你可以说明是相对于原始尺寸还是当前尺寸缩放形状。For images, you can indicate whether you want to scale the shape relative to the original or the current size. 对于除图片以外的其他形状来说,缩放总是相对于其当前宽度而言。Shapes other than pictures are always scaled relative to their current width.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

scaleWidth(scaleFactor: number, scaleType: Excel.ShapeScaleType, scaleFrom?: Excel.ShapeScaleFrom): void;

参数

scaleFactor
number

指定形状调整后的宽度与当前或原始宽度的比例。Specifies the ratio between the width of the shape after you resize it and the current or original width.

scaleType
Excel.ShapeScaleType

指定是相对于形状的原始尺寸还是当前尺寸来对其进行缩放。Specifies whether the shape is scaled relative to its original or current size. 原始大小缩放选项仅适用于图像。The original size scaling option only works for images.

scaleFrom
Excel.ShapeScaleFrom

可选。Optional. 指定在缩放形状时,该形状的哪一部分将保持在原有的位置。Specifies which part of the shape retains its position when the shape is scaled. 如果省略, 则表示形状的左上角将保留其位置。If omitted, it represents the shape's upper left corner retains its position.

返回

void

scaleWidth(scaleFactor, scaleTypeString, scaleFrom)

按指定因子缩放形状的宽度。Scales the width of the shape by a specified factor. 对于图像,你可以说明是相对于原始尺寸还是当前尺寸缩放形状。For images, you can indicate whether you want to scale the shape relative to the original or the current size. 对于除图片以外的其他形状来说,缩放总是相对于其当前宽度而言。Shapes other than pictures are always scaled relative to their current width.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

scaleWidth(scaleFactor: number, scaleTypeString: "CurrentSize" | "OriginalSize", scaleFrom?: "ScaleFromTopLeft" | "ScaleFromMiddle" | "ScaleFromBottomRight"): void;

参数

scaleFactor
number

指定形状调整后的宽度与当前或原始宽度的比例。Specifies the ratio between the width of the shape after you resize it and the current or original width.

scaleTypeString
"CurrentSize" | "OriginalSize"

指定是相对于形状的原始尺寸还是当前尺寸来对其进行缩放。Specifies whether the shape is scaled relative to its original or current size. 原始大小缩放选项仅适用于图像。The original size scaling option only works for images.

scaleFrom
"ScaleFromTopLeft" | "ScaleFromMiddle" | "ScaleFromBottomRight"

可选。Optional. 指定在缩放形状时,该形状的哪一部分将保持在原有的位置。Specifies which part of the shape retains its position when the shape is scaled. 如果省略, 则表示形状的左上角将保留其位置。If omitted, it represents the shape's upper left corner retains its position.

返回

void

set(properties, options)

同时设置一个对象的多个属性。Sets multiple properties of an object at the same time. 您可以传递具有相应属性的纯对象或相同类型的其他 API 对象。You can pass either a plain object with the appropriate properties, or another API object of the same type.

set(properties: Interfaces.ShapeUpdateData, options?: OfficeExtension.UpdateOptions): void;

参数

properties
Interfaces.ShapeUpdateData

一个 JavaScript 对象, 其属性的结构 isomorphically 为在其上调用方法的对象的属性。A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called.

options
OfficeExtension.UpdateOptions

提供一个选项, 以在 properties 对象尝试设置任何只读属性时禁止显示错误。Provides an option to suppress errors if the properties object tries to set any read-only properties.

返回

void

注解

此方法具有以下附加签名:This method has the following additional signature:

set(properties: Excel.Shape): void

set(properties)

基于现有加载的对象同时设置该对象的多个属性。Sets multiple properties on the object at the same time, based on an existing loaded object.

set(properties: Excel.Shape): void;

参数

properties
Excel.Shape

返回

void

setZOrder(position)

将指定形状沿集合的 z 顺序向上或向下移动,将其移动到其他形状的前面或后面。Moves the specified shape up or down the collection's z-order, which shifts it in front of or behind other shapes.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

setZOrder(position: Excel.ShapeZOrder): void;

参数

position
Excel.ShapeZOrder

相对于其他形状在 z-顺序堆栈中移动形状的位置。Where to move the shape in the z-order stack relative to the other shapes. 有关详细信息, 请参阅 ShapeZOrder。See Excel.ShapeZOrder for details.

返回

void

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Shapes");
    const shape = sheet.shapes.getItem("Octagon")
    shape.setZOrder(Excel.ShapeZOrder.sendBackward);
    await context.sync();
});

setZOrder(positionString)

将指定形状沿集合的 z 顺序向上或向下移动,将其移动到其他形状的前面或后面。Moves the specified shape up or down the collection's z-order, which shifts it in front of or behind other shapes.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

setZOrder(positionString: "BringToFront" | "BringForward" | "SendToBack" | "SendBackward"): void;

参数

positionString
"BringToFront" | "BringForward" | "SendToBack" | "SendBackward"

相对于其他形状在 z-顺序堆栈中移动形状的位置。Where to move the shape in the z-order stack relative to the other shapes. 有关详细信息, 请参阅 ShapeZOrder。See Excel.ShapeZOrder for details.

返回

void

toJSON()

重写 JavaScript toJSON()方法, 以便在将 API 对象传递到时提供更有用的输出JSON.stringify()Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify反过来, 也会调用传递toJSON给它的对象的方法。尽管原始的 Excel. Shape 对象是 API 对象, 但toJSON方法返回一个简单的 JavaScript 对象 (类型为Excel.Interfaces.ShapeData, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.Shape object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.ShapeData), 其中包含原始对象中所有已加载的子属性的浅表副本。) that contains shallow copies of any loaded child properties from the original object.

toJSON(): Excel.Interfaces.ShapeData;

返回

事件详细信息

onActivated

当激活形状时发生此事件。Occurs when the shape is activated.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly onActivated: OfficeExtension.EventHandlers<Excel.ShapeActivatedEventArgs>;

返回

OfficeExtension.EventHandlers<Excel.ShapeActivatedEventArgs>

onDeactivated

当停用形状时发生此事件。Occurs when the shape is deactivated.

[API 集: ExcelApi 1.9][ API set: ExcelApi 1.9 ]

readonly onDeactivated: OfficeExtension.EventHandlers<Excel.ShapeDeactivatedEventArgs>;

返回

OfficeExtension.EventHandlers<Excel.ShapeDeactivatedEventArgs>