I am working on a Windows 7 gadget that is supposed to extract data from an excel document. The problem is that the Excel process will not be unloaded after I retrieve the data I need.
Here is the code that I use in my initialization function:
var Excel = new ActiveXObject("Excel.Application"); Excel.Visible = false; Excel.DisplayAlerts = false; var workbooks = Excel.Workbooks; var workbook = workbooks.Open("\\\\SERVER\\Documents\\Sample.xlsx", 0, true); var activesheet = workbook.ActiveSheet; var cell = sheet.Cells(1, 1); var value = cell.Value; document.getElementById("content").innerHTML = value; delete value; value = null; delete cell; cell = null; delete activesheet; activesheet = null; delete workbook; workbook = null; delete workbooks; workbooks = null; Excel.Quit(); delete Excel; Excel = null;
This is all wrapped in a try-catch block, and I can verify that all of this succeeds. All remote and null assignments are my attempt to release any references to COM objects, but I seem to be missing something. Is there a way to get the Excel process to unload?
source share