[]
        
(Showing Draft Content)

Connector Shapes

A connector is used when you need to connect or disconnect two general shapes. In DsExcel, you can add connectors at specific coordinates or a specific range of a worksheet using the addConnector method. You can also use the BeginConnect method, EndConnect method, BeginDisconnect method and EndDisconnect method of the IConnectorFormat interface to attach and detach the ends of the connector to other shapes.

Refer to the following example code to connect general shapes using the connector format. You can add a Connector by providing the connector position in points, or add a connector directly to a range.

// To configure the connector shape
IShape ShapeBegin = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 1, 1, 100, 100);
IShape EndBegin = worksheet.getShapes().addShape(AutoShapeType.Rectangle, 200, 200, 100, 100);
IShape ConnectorShape = worksheet.getShapes().addConnector(ConnectorType.Straight, 1, 1, 101, 101);
ConnectorShape.Width=10;
        
// To detach the ends of the connector to other shapes
ConnectorShape.getConnectorFormat().beginConnect(ShapeBegin, 3);
ConnectorShape.getConnectorFormat().endConnect(EndBegin, 0);
        
// Add shape using range
IShape rectangle3 = worksheet.getShapes.addShape(AutoShapeType.Rectangle, worksheet.Range["B12"]);
IShape rectangle4 = worksheet.getShapes.addShape(AutoShapeType.Rectangle, worksheet.Range["D12"]);

//Add connector for rectangle3 and rectangle4, by adding connector directly to a range
IShape rangeConnectorShape = worksheet.getShapes().addConnector(ConnectorType.Curve, worksheet.Range["B12:D12"]);

Note: One of the limitations of using connector format is that you can add a connector to connect two general shapes and export it but the connector will be shown only after you drag the shape to your spreadsheet.