Articles in this section
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()

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied