ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel Download using Microsoft.Interop.Excel (https://www.excelbanter.com/excel-programming/439243-excel-download-using-microsoft-interop-excel.html)

seshadri

Excel Download using Microsoft.Interop.Excel
 

We are using Microsoft.Interop.Excel in our dotnet web application for
downloading the data in the excel.

Once the download is completed the excel object is not getting killed or
released from the memory automatically (The EXCEL.EXE*32 process still
appears in the Task Manager).

When ever the "Download" button is clicked a new EXCEL.EXE process is
getting created but not cleared disposed from the memory.

This EXCEL.EXE process resides in the task manager unless it is killed
manually.

Below is the code block which we have written to dispose the excel object
from the memory.

/* Code Block starts */

Excelworkbook.Close(false, WorkBookPath, false);
Excelapp.Quit();

System.Runtime.InteropServices.Marshal.ReleaseComO bject(objExcelcellRange);

System.Runtime.InteropServices.Marshal.ReleaseComO bject(objExcelworksheet);

System.Runtime.InteropServices.Marshal.ReleaseComO bject(objExcelsheets);

System.Runtime.InteropServices.Marshal.ReleaseComO bject(objExcelworkbook);

System.Runtime.InteropServices.Marshal.ReleaseComO bject(objexcelapp);
objExcelworksheet = null;
objExcelsheets = null;
objExcelworkbook = null;
objExcelapp = null;
GC.Collect();

/* Code Block ends */

Steps we tried to resolve this issue

1. Added "Network Service" User in the DCOMCONFIG -- Microsoft Excel
Application -- Security -- Configuration Settings and gave full control.

The above step didn't work.

Please suggest how we can dispose the EXCEL object from the memory using
Interop services through code.

Thank you.



All times are GMT +1. The time now is 01:39 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com