Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Excel Interop : Excel process remains in memory until parent form closed
    primarykey
    data
    text
    <p>In my form I am doing something as simple as</p> <pre><code>private void btnPrintPickList_Click(object sender, EventArgs e) { using (var salesRpt = new SalesOrder(CurrentItem())) { salesRpt.CreateSpreadSheet(); salesRpt.Dispose(); } } </code></pre> <p>I have followed the "no 2 dots rule for excel interop".</p> <pre><code>protected ExcelSheet(bool documentVisible, XlPageOrientation orientation) { ExcelApplication = new Application {Visible = documentVisible}; WorkBooks = ExcelApplication.Workbooks; WorkBook = WorkBooks.Add(XlSheetType.xlWorksheet); SheetList = WorkBook.Worksheets; Orientation = orientation; WorkSheet = (Worksheet) ExcelApplication.ActiveSheet; } public Application ExcelApplication { get; private set; } public Workbook WorkBook { get; private set; } public Workbooks WorkBooks { get; private set; } public Worksheet WorkSheet { get; private set; } public Sheets SheetList { get; private set; } public XlPageOrientation Orientation { get; private set; } </code></pre> <p>the dispose method does the following.</p> <pre><code> public void Dispose() { for (int i = 1; i &lt;= SheetList.Count; i++) { Marshal.FinalReleaseComObject(SheetList[i]); } //Marshal.FinalReleaseComObject(WorkSheet); Marshal.FinalReleaseComObject(SheetList); Marshal.FinalReleaseComObject(WorkBook); WorkBooks.Close(); Marshal.FinalReleaseComObject(WorkBooks); ExcelApplication.Quit(); Marshal.FinalReleaseComObject(ExcelApplication); WorkSheet = null; SheetList = null; WorkBook = null; WorkBooks = null; ExcelApplication = null; } </code></pre> <p>In my testing, the EXCEL.exe process does not consistently get removed from the current processes in the taskbar once the Excel spreadsheet is printed.</p> <p>What am I doing wrong? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload