Category / Section
When to call Dispose in XlsIO?
1 min read
ExcelEngine.Dispose() must be invoked after closing the workbook.
For ex. If an excel file is created/opened and saved after some manipulation, it has to be disposed. Please refer the below code example to dispose the ExcelEngine.
C#
ExcelEngine excelEngine = new ExcelEngine(); IApplication application = excelEngine.Excel; IWorkbook workbook = application.Workbooks.Create(1); //Do some manipulation workbook.SaveAs(fileName); workbook.Close(); excelEngine.Dispose();
VB
Dim excelEngine As ExcelEngine = New ExcelEngine() Dim application As IApplication = excelEngine.Excel Dim workbook As IWorkbook = application.Workbooks.Create(1) 'Do some manipulation workbook.SaveAs(fileName) workbook.Close() excelEngine.Dispose()