Release Unmanaged Resources of the Workbook with Python via .NET
Contents
[
Hide
]
Aspose.Cells provides the workbook.close() method to release unmanaged resources of the Workbook object. This pattern is crucial for handling unmanaged resources like file handles, streams, or memory allocations that aren’t automatically managed by Python’s garbage collector.
The Workbook class implements Python’s context manager protocol for resource management. You can either explicitly call the close() method or use Python’s with
statement to ensure proper cleanup.
from aspose.cells import Workbook
# Create workbook object
with aspose.cells.Workbook() as wb:
wb.save("dispose.xlsx")
pass