Excel.Line class

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

Extends

Remarks

[ API set: ExcelApi 1.9 ]

Properties

beginArrowheadLength

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

beginArrowheadStyle

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

beginArrowheadWidth

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

beginConnectedShape

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

beginConnectedSite

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

connectorType

Represents the connector type for the line.

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.

endArrowheadStyle

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

endArrowheadWidth

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

endConnectedShape

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

endConnectedSite

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

id

Specifies the shape identifier.

isBeginConnected

Specifies if the beginning of the specified line is connected to a shape.

isEndConnected

Specifies if the end of the specified line is connected to a shape.

shape

Returns the Shape object associated with the line.

Methods

connectBeginShape(shape, connectionSite)

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

connectEndShape(shape, connectionSite)

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

disconnectBeginShape()

Detaches the beginning of the specified connector from a shape.

disconnectEndShape()

Detaches the end of the specified connector from a shape.

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.

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

Property Value

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

Remarks

[ API set: ExcelApi 1.9 ]

beginArrowheadStyle

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

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

Property Value

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

Remarks

[ API set: ExcelApi 1.9 ]

beginArrowheadWidth

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

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

Property Value

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

Remarks

[ API set: ExcelApi 1.9 ]

beginConnectedShape

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

readonly beginConnectedShape: Excel.Shape;

Property Value

Remarks

[ API set: ExcelApi 1.9 ]

beginConnectedSite

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

readonly beginConnectedSite: number;

Property Value

number

Remarks

[ API set: ExcelApi 1.9 ]

connectorType

Represents the connector type for the line.

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

Property Value

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

Remarks

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

context: RequestContext;

Property Value

endArrowheadLength

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

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

Property Value

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

Remarks

[ API set: ExcelApi 1.9 ]

endArrowheadStyle

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

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

Property Value

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

Remarks

[ API set: ExcelApi 1.9 ]

endArrowheadWidth

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

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

Property Value

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

Remarks

[ API set: ExcelApi 1.9 ]

endConnectedShape

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

readonly endConnectedShape: Excel.Shape;

Property Value

Remarks

[ API set: ExcelApi 1.9 ]

endConnectedSite

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

readonly endConnectedSite: number;

Property Value

number

Remarks

[ API set: ExcelApi 1.9 ]

id

Specifies the shape identifier.

readonly id: string;

Property Value

string

Remarks

[ API set: ExcelApi 1.9 ]

isBeginConnected

Specifies if the beginning of the specified line is connected to a shape.

readonly isBeginConnected: boolean;

Property Value

boolean

Remarks

[ API set: ExcelApi 1.9 ]

isEndConnected

Specifies if the end of the specified line is connected to a shape.

readonly isEndConnected: boolean;

Property Value

boolean

Remarks

[ API set: ExcelApi 1.9 ]

shape

Returns the Shape object associated with the line.

readonly shape: Excel.Shape;

Property Value

Remarks

[ API set: ExcelApi 1.9 ]

Method Details

connectBeginShape(shape, connectionSite)

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

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

Remarks

[ API set: ExcelApi 1.9 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml

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.

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

Remarks

[ API set: ExcelApi 1.9 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml

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.

disconnectBeginShape(): void;

Returns

void

Remarks

[ API set: ExcelApi 1.9 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml

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.

disconnectEndShape(): void;

Returns

void

Remarks

[ API set: ExcelApi 1.9 ]

Examples

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/44-shape/shape-lines.yaml

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

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