public new void Dispose()
{
try
{
this.SuspendLayout();
foreach (SheetView sheet in this.Sheets)
{
var shapes = sheet.DrawingContainer.ContainedObjects;
if (shapes != null)
{
foreach (var item in shapes)
{
var shape = item as PSShape;
if (shape != null)
{
shape.Dispose(true);
}
}
}
try
{
if (sheet.Charts != null)
{
sheet.Charts.Clear();
}
if (shapes != null)
{
shapes.Clear();
}
sheet.ClearShapes();
sheet.Rows.Clear();
sheet.Columns.Clear();
}
finally
{
sheet.Dispose();
}
}
this.Sheets.Clear();
}
catch (Exception ex)
{
LoggingService.Error("释放内存失败:"+ex);
}
base.Dispose(true);
GC.SuppressFinalize(this);
} |