Excel.Line class

Represents a line inside a worksheet. To get the corresponding Shape object, use Line.shape.

[ API set: ExcelApi 1.9 ]

Extends
OfficeExtension.ClientObject

Properties

beginArrowheadLength

Represents the length of the arrowhead at the beginning of the specified line.

[ API set: ExcelApi 1.9 ]

beginArrowheadStyle

Represents the style of the arrowhead at the beginning of the specified line.

[ API set: ExcelApi 1.9 ]

beginArrowheadWidth

Represents the width of the arrowhead at the beginning of the specified line.

[ API set: ExcelApi 1.9 ]

beginConnectedShape

Represents the shape to which the beginning of the specified line is attached. Read-only.

[ API set: ExcelApi 1.9 ]

beginConnectedSite

Represents the connection site to which the beginning of a connector is connected. Read-only. Returns null when the beginning of the line is not attached to any shape.

[ API set: ExcelApi 1.9 ]

connectorType

Represents the connector type for the line.

[ API set: ExcelApi 1.9 ]

context

The request context associated with the object. 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 set: ExcelApi 1.9 ]

endArrowheadStyle

Represents the style of the arrowhead at the end of the specified line.

[ API set: ExcelApi 1.9 ]

endArrowheadWidth

Represents the width of the arrowhead at the end of the specified line.

[ API set: ExcelApi 1.9 ]

endConnectedShape

Represents the shape to which the end of the specified line is attached. Read-only.

[ API set: ExcelApi 1.9 ]

endConnectedSite

Represents the connection site to which the end of a connector is connected. Read-only. Returns null when the end of the line is not attached to any shape.

[ API set: ExcelApi 1.9 ]

id

Represents the shape identifier. Read-only.

[ API set: ExcelApi 1.9 ]

isBeginConnected

Specifies whether or not the beginning of the specified line is connected to a shape. Read-only.

[ API set: ExcelApi 1.9 ]

isEndConnected

Specifies whether or not the end of the specified line is connected to a shape. Read-only.

[ API set: ExcelApi 1.9 ]

shape

Returns the Shape object associated with the line. Read-only.

[ API set: ExcelApi 1.9 ]

Methods

connectBeginShape(shape, connectionSite)

Attaches the beginning of the specified connector to a specified shape.

[ API set: ExcelApi 1.9 ]

connectEndShape(shape, connectionSite)

Attaches the end of the specified connector to a specified shape.

[ API set: ExcelApi 1.9 ]

disconnectBeginShape()

Detaches the beginning of the specified connector from a shape.

[ API set: ExcelApi 1.9 ]

disconnectEndShape()

Detaches the end of the specified connector from a shape.

[ API set: ExcelApi 1.9 ]

load(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

set(properties, options)

Sets multiple properties of an object at the same time. 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()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, 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.

Property Details

beginArrowheadLength

Represents the length of the arrowhead at the beginning of the specified line.

[ API set: ExcelApi 1.9 ]

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

Property Value

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

beginArrowheadStyle

Represents the style of the arrowhead at the beginning of the specified line.

[ API set: ExcelApi 1.9 ]

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

Property Value

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

beginArrowheadWidth

Represents the width of the arrowhead at the beginning of the specified line.

[ API set: ExcelApi 1.9 ]

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

Property Value

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

beginConnectedShape

Represents the shape to which the beginning of the specified line is attached. Read-only.

[ API set: ExcelApi 1.9 ]

readonly beginConnectedShape: Excel.Shape;

Property Value

beginConnectedSite

Represents the connection site to which the beginning of a connector is connected. Read-only. Returns null when the beginning of the line is not attached to any shape.

[ API set: ExcelApi 1.9 ]

readonly beginConnectedSite: number;

Property Value

number

connectorType

Represents the connector type for the line.

[ API set: ExcelApi 1.9 ]

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

Property Value

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

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

endArrowheadLength

Represents the length of the arrowhead at the end of the specified line.

[ API set: ExcelApi 1.9 ]

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

Property Value

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

endArrowheadStyle

Represents the style of the arrowhead at the end of the specified line.

[ API set: ExcelApi 1.9 ]

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

Property Value

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

endArrowheadWidth

Represents the width of the arrowhead at the end of the specified line.

[ API set: ExcelApi 1.9 ]

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

Property Value

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

endConnectedShape

Represents the shape to which the end of the specified line is attached. Read-only.

[ API set: ExcelApi 1.9 ]

readonly endConnectedShape: Excel.Shape;

Property Value

endConnectedSite

Represents the connection site to which the end of a connector is connected. Read-only. Returns null when the end of the line is not attached to any shape.

[ API set: ExcelApi 1.9 ]

readonly endConnectedSite: number;

Property Value

number

id

Represents the shape identifier. Read-only.

[ API set: ExcelApi 1.9 ]

readonly id: string;

Property Value

string

isBeginConnected

Specifies whether or not the beginning of the specified line is connected to a shape. Read-only.

[ API set: ExcelApi 1.9 ]

readonly isBeginConnected: boolean;

Property Value

boolean

isEndConnected

Specifies whether or not the end of the specified line is connected to a shape. Read-only.

[ API set: ExcelApi 1.9 ]

readonly isEndConnected: boolean;

Property Value

boolean

shape

Returns the Shape object associated with the line. Read-only.

[ API set: ExcelApi 1.9 ]

readonly shape: Excel.Shape;

Property Value

Method Details

connectBeginShape(shape, connectionSite)

Attaches the beginning of the specified connector to a specified shape.

[ API set: ExcelApi 1.9 ]

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

Parameters

shape
Excel.Shape

The shape to connect.

connectionSite
number

The connection site on the shape to which the beginning of the connector is attached. Must be an integer between 0 (inclusive) and the connection-site count of the specified shape (exclusive).

Returns

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 set: ExcelApi 1.9 ]

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

Parameters

shape
Excel.Shape

The shape to connect.

connectionSite
number

The connection site on the shape to which the end of the connector is attached. Must be an integer between 0 (inclusive) and the connection-site count of the specified shape (exclusive).

Returns

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 set: ExcelApi 1.9 ]

disconnectBeginShape(): void;

Returns

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 set: ExcelApi 1.9 ]

disconnectEndShape(): void;

Returns

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(options)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

load(options?: Excel.Interfaces.LineLoadOptions): Excel.Line;

Parameters

options
Excel.Interfaces.LineLoadOptions

Provides options for which properties of the object to load.

Returns

load(propertyNames)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

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

Parameters

propertyNames
string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

load(propertyNamesAndPaths)

Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.

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

Parameters

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

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.

Returns

set(properties, options)

Sets multiple properties of an object at the same time. 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;

Parameters

properties
Interfaces.LineUpdateData

A JavaScript object with properties that are structured isomorphically to the properties of the object on which the method is called.

options
OfficeExtension.UpdateOptions

Provides an option to suppress errors if the properties object tries to set any read-only properties.

Returns

void

Remarks

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;

Parameters

properties
Excel.Line

Returns

void

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, 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;

Returns