Excel.Line class

代表工作表中的一条线。Represents a line inside a worksheet. 若要获取相应的 Shape 对象, 请使用Line.shapeTo get the corresponding Shape object, use Line.shape.

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

Extends

属性

beginArrowheadLength

表示指定线条始端的箭头长度。Represents the length of the arrowhead at the beginning of the specified line.

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

beginArrowheadStyle

表示指定线条始端的箭头样式。Represents the style of the arrowhead at the beginning of the specified line.

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

beginArrowheadWidth

表示指定线条始端的箭头宽度。Represents the width of the arrowhead at the beginning of the specified line.

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

beginConnectedShape

表示指定线条始端所附加到的形状。Represents the shape to which the beginning of the specified line is attached. 只读。Read-only.

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

beginConnectedSite

表示连接线始端所连接的连接站点。Represents the connection site to which the beginning of a connector is connected. 只读。Read-only. 当线条的始端没有附加到任何形状时,返回 null。Returns null when the beginning of the line is not attached to any shape.

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

connectorType

表示线条的连接器类型。Represents the connector type for the line.

[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.

endArrowheadLength

表示指定线条末端的箭头长度。Represents the length of the arrowhead at the end of the specified line.

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

endArrowheadStyle

表示指定线条末端的箭头样式。Represents the style of the arrowhead at the end of the specified line.

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

endArrowheadWidth

表示指定线条末端的箭头宽度。Represents the width of the arrowhead at the end of the specified line.

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

endConnectedShape

表示指定线条末端所附加到的形状。Represents the shape to which the end of the specified line is attached. 只读。Read-only.

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

endConnectedSite

表示连接线末端所连接的连接站点。Represents the connection site to which the end of a connector is connected. 只读。Read-only. 当线条的末端没有附加到任何形状时,返回 null。Returns null when the end of the line is not attached to any shape.

[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 ]

isBeginConnected

指定指定线条的始端是否连接到形状。Specifies whether or not the beginning of the specified line is connected to a shape. 只读。Read-only.

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

isEndConnected

指定指定线条的末端是否连接到形状。Specifies whether or not the end of the specified line is connected to a shape. 只读。Read-only.

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

shape

返回与线条关联的形状对象。Returns the Shape object associated with the line. 只读。Read-only.

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

方法

connectBeginShape(shape, connectionSite)

将指定连接线的始端附加到指定形状。Attaches the beginning of the specified connector to a specified shape.

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

connectEndShape(shape, connectionSite)

将指定连接线的末端附加到指定形状。Attaches the end of the specified connector to a specified shape.

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

disconnectBeginShape()

使指定连接线的始端与形状脱离。Detaches the beginning of the specified connector from a shape.

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

disconnectEndShape()

使指定连接线的末端与形状脱离。Detaches the end of the specified connector from a shape.

[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.

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.

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 Line 对象是 API 对象, 但toJSON方法返回一个无格式的 JavaScript 对象 (类型为Excel.Interfaces.LineData, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.Line object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.LineData), 其中包含原始对象中所有已加载的子属性的浅表副本。) that contains shallow copies of any loaded child properties from the original object.

属性详细信息

beginArrowheadLength

表示指定线条始端的箭头长度。Represents the length of the arrowhead at the beginning of the specified line.

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

beginArrowheadLength: Excel.ArrowheadLength | "Short" | "Medium" | "Long";

属性值

Excel.ArrowheadLength | "Short" | "Medium" | "Long"

beginArrowheadStyle

表示指定线条始端的箭头样式。Represents the style of the arrowhead at the beginning of the specified line.

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

beginArrowheadStyle: Excel.ArrowheadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open";

属性值

Excel.ArrowheadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open"

beginArrowheadWidth

表示指定线条始端的箭头宽度。Represents the width of the arrowhead at the beginning of the specified line.

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

beginArrowheadWidth: Excel.ArrowheadWidth | "Narrow" | "Medium" | "Wide";

属性值

Excel.ArrowheadWidth | "Narrow" | "Medium" | "Wide"

beginConnectedShape

表示指定线条始端所附加到的形状。Represents the shape to which the beginning of the specified line is attached. 只读。Read-only.

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

readonly beginConnectedShape: Excel.Shape;

属性值

beginConnectedSite

表示连接线始端所连接的连接站点。Represents the connection site to which the beginning of a connector is connected. 只读。Read-only. 当线条的始端没有附加到任何形状时,返回 null。Returns null when the beginning of the line is not attached to any shape.

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

readonly beginConnectedSite: number;

属性值

number

connectorType

表示线条的连接器类型。Represents the connector type for the line.

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

connectorType: Excel.ConnectorType | "Straight" | "Elbow" | "Curve";

属性值

Excel.ConnectorType | "Straight" | "Elbow" | "Curve"

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

endArrowheadLength

表示指定线条末端的箭头长度。Represents the length of the arrowhead at the end of the specified line.

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

endArrowheadLength: Excel.ArrowheadLength | "Short" | "Medium" | "Long";

属性值

Excel.ArrowheadLength | "Short" | "Medium" | "Long"

endArrowheadStyle

表示指定线条末端的箭头样式。Represents the style of the arrowhead at the end of the specified line.

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

endArrowheadStyle: Excel.ArrowheadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open";

属性值

Excel.ArrowheadStyle | "None" | "Triangle" | "Stealth" | "Diamond" | "Oval" | "Open"

endArrowheadWidth

表示指定线条末端的箭头宽度。Represents the width of the arrowhead at the end of the specified line.

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

endArrowheadWidth: Excel.ArrowheadWidth | "Narrow" | "Medium" | "Wide";

属性值

Excel.ArrowheadWidth | "Narrow" | "Medium" | "Wide"

endConnectedShape

表示指定线条末端所附加到的形状。Represents the shape to which the end of the specified line is attached. 只读。Read-only.

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

readonly endConnectedShape: Excel.Shape;

属性值

endConnectedSite

表示连接线末端所连接的连接站点。Represents the connection site to which the end of a connector is connected. 只读。Read-only. 当线条的末端没有附加到任何形状时,返回 null。Returns null when the end of the line is not attached to any shape.

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

readonly endConnectedSite: number;

属性值

number

id

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

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

readonly id: string;

属性值

string

isBeginConnected

指定指定线条的始端是否连接到形状。Specifies whether or not the beginning of the specified line is connected to a shape. 只读。Read-only.

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

readonly isBeginConnected: boolean;

属性值

boolean

isEndConnected

指定指定线条的末端是否连接到形状。Specifies whether or not the end of the specified line is connected to a shape. 只读。Read-only.

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

readonly isEndConnected: boolean;

属性值

boolean

shape

返回与线条关联的形状对象。Returns the Shape object associated with the line. 只读。Read-only.

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

readonly shape: Excel.Shape;

属性值

方法详细信息

connectBeginShape(shape, connectionSite)

将指定连接线的始端附加到指定形状。Attaches the beginning of the specified connector to a specified shape.

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

connectBeginShape(shape: Excel.Shape, connectionSite: number): void;

参数

shape
Excel.Shape

要连接的形状。The shape to connect.

connectionSite
number

连接符的起点所附加到的形状上的连接点。The connection site on the shape to which the beginning of the connector is attached. 必须是介于 0 (含) 和指定形状的连接网站数 (独占) 之间的整数。Must be an integer between 0 (inclusive) and the connection-site count of the specified shape (exclusive).

返回

void

示例Examples

await Excel.run(async (context) => {
    const shapes = context.workbook.worksheets.getItem("Shapes").shapes;
    const line = shapes.getItem("StraightLine").line;
    line.connectBeginShape(shapes.getItem("Left"), 2);
    line.connectEndShape(shapes.getItem("Right"), 0);
    await context.sync();
});

connectEndShape(shape, connectionSite)

将指定连接线的末端附加到指定形状。Attaches the end of the specified connector to a specified shape.

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

connectEndShape(shape: Excel.Shape, connectionSite: number): void;

参数

shape
Excel.Shape

要连接的形状。The shape to connect.

connectionSite
number

连接符的终点所连接的形状上的连接点。The connection site on the shape to which the end of the connector is attached. 必须是介于 0 (含) 和指定形状的连接网站数 (独占) 之间的整数。Must be an integer between 0 (inclusive) and the connection-site count of the specified shape (exclusive).

返回

void

示例Examples

await Excel.run(async (context) => {
    const shapes = context.workbook.worksheets.getItem("Shapes").shapes;
    const line = shapes.getItem("StraightLine").line;
    line.connectBeginShape(shapes.getItem("Left"), 2);
    line.connectEndShape(shapes.getItem("Right"), 0);
    await context.sync();
});

disconnectBeginShape()

使指定连接线的始端与形状脱离。Detaches the beginning of the specified connector from a shape.

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

disconnectBeginShape(): void;

返回

void

示例Examples

await Excel.run(async (context) => {
    const shapes = context.workbook.worksheets.getItem("Shapes").shapes;
    const line = shapes.getItem("StraightLine").line;
    line.disconnectBeginShape();
    line.disconnectEndShape();
    await context.sync();
});

disconnectEndShape()

使指定连接线的末端与形状脱离。Detaches the end of the specified connector from a shape.

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

disconnectEndShape(): void;

返回

void

示例Examples

await Excel.run(async (context) => {
    const shapes = context.workbook.worksheets.getItem("Shapes").shapes;
    const line = shapes.getItem("StraightLine").line;
    line.disconnectBeginShape();
    line.disconnectEndShape();
    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.LineLoadOptions): Excel.Line;

参数

返回

注解

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

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

参数

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.Line;

参数

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.

返回

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.LineUpdateData, options?: OfficeExtension.UpdateOptions): void;

参数

properties
Interfaces.LineUpdateData

一个 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.Line): void

set(properties)

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

set(properties: Excel.Line): void;

参数

properties
Excel.Line

返回

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 Line 对象是 API 对象, 但toJSON方法返回一个无格式的 JavaScript 对象 (类型为Excel.Interfaces.LineData, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.Line object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.LineData), 其中包含原始对象中所有已加载的子属性的浅表副本。) that contains shallow copies of any loaded child properties from the original object.

toJSON(): Excel.Interfaces.LineData;

返回