In Aspose.Cells for .Net v 4.7.x.x we had code that looked like:
Sub RemovePictures( ByVal ws As Worksheet )
Do While ws.Shapes.Count > 0
ws.Shapes.RemoveAt(0) ’ delete the shapes
Loop
Do While ws.Pictures.Count > 0
ws.Pictures.RemoveAt(0) ’ delete the pictures
Loop
End Sub
This removed any pictures and drawings within the sheet.
In Aspose.Cells for .Net v4.8.0.0 this code fails within the Pictures.RemoveAt method with an IndexOutOfRange error - it appears to be trying to delete the Shape that has already been removed.
A work around for this situation is to remove the Pictures first:
Sub RemovePictures( ByVal ws As Worksheet )
Do While ws.Pictures.Count > 0
ws.Pictures.RemoveAt(0) ' delete the pictures<br>
Loop
Do While ws.Shapes.Count > 0
ws.Shapes.RemoveAt(0) ' delete the shapes<br>
Loop
End Sub
Ideally the Pictures.RemoveAt() shouldn’t fail if the shape has already been deleted and a more appropriate error message thrown.