Skip to main content
A newer version of this page is available. .
.NET Framework 4.5.2+
Row

ShapeCollection.Flatten() Method

Converts a shape collection into a flattened collection that contains all drawing objects in a worksheet, including items of shape groups.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v19.1.Core.dll

Declaration

IEnumerable<Shape> Flatten()

Returns

Type Description
IEnumerable<Shape>

A flattened collection of drawing objects in a worksheet.

Remarks

The ShapeCollection contains the standalone drawing objects and shape groups. It stores each group as a single shape and does not include the group’s items. Use the group’s Shape.GetChildren method to iterate through its elements.

The Flatten method recursively iterates through the ShapeCollection and its groups to retrieve all drawing object contained in a worksheet. If you need to obtain drawing objects of a specific type, filter the resulting collection by ShapeType.

For instance, the following code snippet shows how to collect all pictures from a worksheet.

using System.Linq;
// ...

var pictures = worksheet.Shapes.Flatten()
    .Where(x => x.ShapeType == ShapeType.Picture)
    .Cast<Picture>();
See Also