Excel.Line class
Represents a line inside a worksheet. To get the corresponding Shape object, use Line.shape.
- Extends
Remarks
Properties
| begin |
Represents the length of the arrowhead at the beginning of the specified line. |
| begin |
Represents the style of the arrowhead at the beginning of the specified line. |
| begin |
Represents the width of the arrowhead at the beginning of the specified line. |
| begin |
Represents the shape to which the beginning of the specified line is attached. |
| begin |
Represents the connection site to which the beginning of a connector is connected. Returns |
| connector |
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. |
| end |
Represents the length of the arrowhead at the end of the specified line. |
| end |
Represents the style of the arrowhead at the end of the specified line. |
| end |
Represents the width of the arrowhead at the end of the specified line. |
| end |
Represents the shape to which the end of the specified line is attached. |
| end |
Represents the connection site to which the end of a connector is connected. Returns |
| id | Specifies the shape identifier. |
| is |
Specifies if the beginning of the specified line is connected to a shape. |
| is |
Specifies if the end of the specified line is connected to a shape. |
| shape | Returns the |
Methods
| connect |
Attaches the beginning of the specified connector to a specified shape. |
| connect |
Attaches the end of the specified connector to a specified shape. |
| disconnect |
Detaches the beginning of the specified connector from a shape. |
| disconnect |
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 |
| load(property |
Queues up a command to load the specified properties of the object. You must call |
| load(property |
Queues up a command to load the specified properties of the object. You must call |
| 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 |
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
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
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
beginConnectedShape
Represents the shape to which the beginning of the specified line is attached.
readonly beginConnectedShape: Excel.Shape;
Property Value
Remarks
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
connectorType
Represents the connector type for the line.
connectorType: Excel.ConnectorType | "Straight" | "Elbow" | "Curve";
Property Value
Excel.ConnectorType | "Straight" | "Elbow" | "Curve"
Remarks
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
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
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
endConnectedShape
Represents the shape to which the end of the specified line is attached.
readonly endConnectedShape: Excel.Shape;
Property Value
Remarks
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
id
Specifies the shape identifier.
readonly id: string;
Property Value
string
Remarks
isBeginConnected
Specifies if the beginning of the specified line is connected to a shape.
readonly isBeginConnected: boolean;
Property Value
boolean
Remarks
isEndConnected
Specifies if the end of the specified line is connected to a shape.
readonly isEndConnected: boolean;
Property Value
boolean
Remarks
shape
Returns the Shape object associated with the line.
readonly shape: Excel.Shape;
Property Value
Remarks
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
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
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
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
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's 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;