The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.

How to: Create a Shape

This example describes how to create a shape and change its form, size, and rotation angle.

Create a Shape

The code sample below illustrates how to use the ShapeCollection.AddShape method to create a shape.

Spreadsheet_AddShape


Worksheet worksheet = workbook.Worksheets[0];
Shape shape = worksheet.Shapes.AddShape(ShapeGeometryPreset.RectangularCallout, 100, 100, 500, 500);

Change a Shape's Form

Use the ShapeGeometry.Preset property to change the drawing object's geometry type. The code sample below shows how to modify a callout to an End action button.

Spreadsheet_Shape_ChangePreset


shape.ShapeGeometry.Preset = ShapeGeometryPreset.ActionButtonEnd;

Resize and Rotate a Shape

Use the following properties to rotate and resize a shape similarly to what appears on the image below.


shape.Rotation = 45;
shape.Width = 300;
shape.Height = 300;

XtraSpreadsheet_Shape_RotateResize

Tip

You can provide a text for a shape. Refer to the How to: Add Text to a Shape topic for more information.