Excel.ShapeCollection class

代表工作表中所有形状的集合。Represents a collection of all the shapes in the worksheet.

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

Extends

属性

context

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

items

获取此集合中已加载的子项。Gets the loaded child items in this collection.

方法

addGeometricShape(geometricShapeType)

将几何形状添加到工作表。Adds a geometric shape to the worksheet. 返回一个 Shape 对象,该对象代表新图形。Returns a Shape object that represents the new shape.

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

addGeometricShape(geometricShapeTypeString)

将几何形状添加到工作表。Adds a geometric shape to the worksheet. 返回一个 Shape 对象,该对象代表新图形。Returns a Shape object that represents the new shape.

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

addGroup(values)

在此集合的工作表中对形状的子集进行分组。Groups a subset of shapes in this collection's worksheet. 返回表示新形状组的 Shape 对象。Returns a Shape object that represents the new group of shapes.

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

addImage(base64ImageString)

从 base64 编码的字符串创建图像并将其添加到工作表。Creates an image from a base64-encoded string and adds it to the worksheet. 返回表示新图片的 Shape 对象。Returns the Shape object that represents the new image.

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

addLine(startLeft, startTop, endLeft, endTop, connectorType)

将线条添加到工作表。Adds a line to worksheet. 返回表示新线条的 Shape 对象。Returns a Shape object that represents the new line.

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

addLine(startLeft, startTop, endLeft, endTop, connectorTypeString)

将线条添加到工作表。Adds a line to worksheet. 返回表示新线条的 Shape 对象。Returns a Shape object that represents the new line.

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

addSvg(xml)

从 XML 字符串创建可缩放的矢量图形 (SVG) 并将其添加到工作表。Creates a scalable vector graphic (SVG) from an XML string and adds it to the worksheet. 返回表示新图片的 Shape 对象。Returns a Shape object that represents the new image.

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

addTextBox(text)

使用提供的文本作为内容,将文本框添加到工作表。Adds a text box to the worksheet with the provided text as the content. 返回表示新文本框的 Shape 对象。Returns a Shape object that represents the new text box.

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

getCount()

返回工作表中的形状数。Returns the number of shapes in the worksheet. 只读。Read-only.

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

getItem(key)

使用其名称或 ID 获取形状。Gets a shape using its Name or ID.

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

getItemAt(index)

使用其在集合中的位置获取形状。Gets a shape using its position in the collection.

[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(option)
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.ShapeCollection对象是 API 对象, 但toJSON方法返回一个无格式的 JavaScript 对象 (类型为Excel.Interfaces.ShapeCollectionData, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.ShapeCollection object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.ShapeCollectionData), 其中包含集合的项中所有加载属性的浅表副本的 "items" 数组。) that contains an "items" array with shallow copies of any loaded properties from the collection's items.

属性详细信息

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

items

获取此集合中已加载的子项。Gets the loaded child items in this collection.

readonly items: Excel.Shape[];

属性值

Excel.Shape[]

方法详细信息

addGeometricShape(geometricShapeType)

将几何形状添加到工作表。Adds a geometric shape to the worksheet. 返回一个 Shape 对象,该对象代表新图形。Returns a Shape object that represents the new shape.

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

addGeometricShape(geometricShapeType: Excel.GeometricShapeType): Excel.Shape;

参数

geometricShapeType
Excel.GeometricShapeType

表示几何形状的类型。Represents the type of the geometric shape. 有关详细信息,请参阅 Excel.GeometricShapeType。See Excel.GeometricShapeType for details.

返回

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Shapes");
    const shape = sheet.shapes.addGeometricShape(Excel.GeometricShapeType.hexagon);
    shape.left = 5;
    shape.top = 5;
    shape.height = 175;
    shape.width = 200;
    await context.sync();
});

addGeometricShape(geometricShapeTypeString)

将几何形状添加到工作表。Adds a geometric shape to the worksheet. 返回一个 Shape 对象,该对象代表新图形。Returns a Shape object that represents the new shape.

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

addGeometricShape(geometricShapeTypeString: "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.Shape;

参数

geometricShapeTypeString
"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"

表示几何形状的类型。Represents the type of the geometric shape. 有关详细信息,请参阅 Excel.GeometricShapeType。See Excel.GeometricShapeType for details.

返回

addGroup(values)

在此集合的工作表中对形状的子集进行分组。Groups a subset of shapes in this collection's worksheet. 返回表示新形状组的 Shape 对象。Returns a Shape object that represents the new group of shapes.

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

addGroup(values: Array<string | Shape>): Excel.Shape;

参数

values
Array<string | Shape>

形状 ID 或 shape 对象的数组。An array of shape ID or shape objects.

返回

示例Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Shapes");
    const square = sheet.shapes.getItem("Square");
    const pentagon = sheet.shapes.getItem("Pentagon");
    const octagon = sheet.shapes.getItem("Octagon");

    const shapeGroup = sheet.shapes.addGroup([square, pentagon, octagon]);
    shapeGroup.name = "Group";
    console.log("Shapes grouped");

    await context.sync();
});

addImage(base64ImageString)

从 base64 编码的字符串创建图像并将其添加到工作表。Creates an image from a base64-encoded string and adds it to the worksheet. 返回表示新图片的 Shape 对象。Returns the Shape object that represents the new image.

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

addImage(base64ImageString: string): Excel.Shape;

参数

base64ImageString
string

以 JPEG 或 PNG 格式表示图像的 base64 编码字符串。A base64-encoded string representing an image in either JPEG or PNG format.

返回

示例Examples

const myFile = <HTMLInputElement>document.getElementById("selectedFile");
const reader = new FileReader();

reader.onload = (event) => {
    Excel.run((context) => {
        const startIndex = (<string>(<FileReader>event.target).result).indexOf("base64,");
        const mybase64 = (<string>(<FileReader>event.target).result).substr(startIndex + 7);
        const sheet = context.workbook.worksheets.getItem("Shapes");
        const image = sheet.shapes.addImage(mybase64);
        image.name = "Image";
        return context.sync();
    });
};

// Read in the image file as a data URL.
reader.readAsDataURL(myFile.files[0]);

addLine(startLeft, startTop, endLeft, endTop, connectorType)

将线条添加到工作表。Adds a line to worksheet. 返回表示新线条的 Shape 对象。Returns a Shape object that represents the new line.

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

addLine(startLeft: number, startTop: number, endLeft: number, endTop: number, connectorType?: Excel.ConnectorType): Excel.Shape;

参数

startLeft
number

从行的起点到工作表的左侧之间的距离 (以磅为单位)。The distance, in points, from the start of the line to the left side of the worksheet.

startTop
number

从行的起始位置到工作表的顶端之间的距离 (以磅为单位)。The distance, in points, from the start of the line to the top of the worksheet.

endLeft
number

从工作表左侧线的末尾到的距离 (以磅为单位)。The distance, in points, from the end of the line to the left of the worksheet.

endTop
number

从行的末尾到工作表的顶端的距离 (以磅为单位)。The distance, in points, from the end of the line to the top of the worksheet.

connectorType
Excel.ConnectorType

代表连接器类型。Represents the connector type. 有关详细信息, 请参阅 ConnectorType。See Excel.ConnectorType for details.

返回

示例Examples

await Excel.run(async (context) => {
    const shapes = context.workbook.worksheets.getItem("Shapes").shapes;
    const line = shapes.addLine(200, 50, 300, 150, Excel.ConnectorType.straight);
    line.name = "StraightLine";
    await context.sync();
});

addLine(startLeft, startTop, endLeft, endTop, connectorTypeString)

将线条添加到工作表。Adds a line to worksheet. 返回表示新线条的 Shape 对象。Returns a Shape object that represents the new line.

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

addLine(startLeft: number, startTop: number, endLeft: number, endTop: number, connectorTypeString?: "Straight" | "Elbow" | "Curve"): Excel.Shape;

参数

startLeft
number

从行的起点到工作表的左侧之间的距离 (以磅为单位)。The distance, in points, from the start of the line to the left side of the worksheet.

startTop
number

从行的起始位置到工作表的顶端之间的距离 (以磅为单位)。The distance, in points, from the start of the line to the top of the worksheet.

endLeft
number

从工作表左侧线的末尾到的距离 (以磅为单位)。The distance, in points, from the end of the line to the left of the worksheet.

endTop
number

从行的末尾到工作表的顶端的距离 (以磅为单位)。The distance, in points, from the end of the line to the top of the worksheet.

connectorTypeString
"Straight" | "Elbow" | "Curve"

代表连接器类型。Represents the connector type. 有关详细信息, 请参阅 ConnectorType。See Excel.ConnectorType for details.

返回

addSvg(xml)

备注

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

从 XML 字符串创建可缩放的矢量图形 (SVG) 并将其添加到工作表。Creates a scalable vector graphic (SVG) from an XML string and adds it to the worksheet. 返回表示新图片的 Shape 对象。Returns a Shape object that represents the new image.

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

addSvg(xml: string): Excel.Shape;

参数

xml
string

一个代表 SVG 的 XML 字符串。An XML string that represents the SVG.

返回

addTextBox(text)

使用提供的文本作为内容,将文本框添加到工作表。Adds a text box to the worksheet with the provided text as the content. 返回表示新文本框的 Shape 对象。Returns a Shape object that represents the new text box.

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

addTextBox(text?: string): Excel.Shape;

参数

text
string

表示将在创建的文本框中显示的文本。Represents the text that will be shown in the created text box.

返回

示例Examples

await Excel.run(async (context) => {
    const shapes = context.workbook.worksheets.getItem("Shapes").shapes;
    const textbox = shapes.addTextBox("A box with text");
    textbox.left = 100;
    textbox.top = 100;
    textbox.height = 20;
    textbox.width = 175;
    textbox.name = "Textbox";
    await context.sync();
});

getCount()

返回工作表中的形状数。Returns the number of shapes in the worksheet. 只读。Read-only.

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

getCount(): OfficeExtension.ClientResult<number>;

返回

OfficeExtension.ClientResult<number>

getItem(key)

使用其名称或 ID 获取形状。Gets a shape using its Name or ID.

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

getItem(key: string): Excel.Shape;

参数

key
string

要检索的形状的名称或 ID。Name or ID of the shape to be retrieved.

返回

getItemAt(index)

使用其在集合中的位置获取形状。Gets a shape using its position in the collection.

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

getItemAt(index: number): Excel.Shape;

参数

index
number

要检索的形状的从零开始的索引。The zero-based index of the shape to be retrieved.

返回

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.ShapeCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.ShapeCollection;

参数

option
Excel.Interfaces.ShapeCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions

返回

注解

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

load(option?: string | string[]): Excel.ShapeCollection-Where 选项是一个逗号分隔的字符串或一个字符串数组, 用于指定要加载的属性。load(option?: string | string[]): Excel.ShapeCollection - 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.ShapeCollection-Where 选项。选择是一个用逗号分隔的字符串, 用于指定要加载的属性和选项。 expand 是一个用逗号分隔的字符串, 用于指定要加载的导航属性。load(option?: { select?: string; expand?: string; }): Excel.ShapeCollection - 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.ShapeCollection-仅适用于集合类型。load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.ShapeCollection - 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.ShapeCollection;

参数

propertyNames
string | string[]

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

返回

load(option)

load(option?: OfficeExtension.LoadOption): Excel.ShapeCollection;

参数

返回

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.ShapeCollection对象是 API 对象, 但toJSON方法返回一个无格式的 JavaScript 对象 (类型为Excel.Interfaces.ShapeCollectionData, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.ShapeCollection object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.ShapeCollectionData), 其中包含集合的项中所有加载属性的浅表副本的 "items" 数组。) that contains an "items" array with shallow copies of any loaded properties from the collection's items.

toJSON(): Excel.Interfaces.ShapeCollectionData;

返回