ShapeCollection.RemoveAt

ShapeCollection.RemoveAt method

Remove the shape.

public void RemoveAt(int index)
ParameterTypeDescription
indexInt32The index of the shape.

Examples

using System;
using Aspose.Cells;
using Aspose.Cells.Drawing;

namespace AsposeCellsExamples
{
    public class ShapeCollectionMethodRemoveAtWithInt32Demo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Get the shapes collection
            ShapeCollection shapes = worksheet.Shapes;

            // Add first rectangle shape
            shapes.AddRectangle(2, 0, 2, 0, 50, 50);
            
            // Add second rectangle shape
            shapes.AddRectangle(6, 0, 2, 0, 30, 30);

            // Remove the first shape at index 0
            shapes.RemoveAt(0);

            // Save the workbook
            workbook.Save("ShapeCollectionRemoveAtDemo.xlsx");
        }
    }
}

See Also