/// <summary> /// Function to do some proper clean up of objects accessed via OLE /// </summary> /// <remarks></remarks> void System.IDisposable.Dispose() { // reset the XLS objects _objXLSheet = null; _objXLBook = null; _objXLApp = null; //note that the application is not closed here because in some cases, you'll want to display the generated document and consequently, the application should not be closed ExcelExportHelper.RestoreCulture(OriginalCulture); }
/// <summary> /// Closes the workbook from memory, exits the application, cleans up the objects, and /// restores the culture. /// </summary> /// <remarks></remarks> public void Close() { //Closes the worksheet , workbook and application without saving _objXLSheet = null; if ((_objXLBook != null)) { _objXLBook.close(false); } _objXLApp.quit(); Marshal.ReleaseComObject(_objXLApp); //Now, restore the culture ExcelExportHelper.RestoreCulture(_originalCulture); }