从JavaScript关闭Excel ActiveX对象会在内存中留下excel.exe [英] Closing Excel ActiveX object from JavaScript leaves excel.exe in memory

查看:221
本文介绍了从JavaScript关闭Excel ActiveX对象会在内存中留下excel.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function gbid(s) {
    return document.getElementById(s);
}

function GetData(cell,row) {
    var excel = new ActiveXObject("Excel.Application");
    var excel_file = excel.Workbooks.Open("Z:/SunCenter/Medicare Customer Experience/Hub/CaliforniaHUB/Plans/H0562_2013_082_EOC.xlsx");
    var excel_sheet = excel.Worksheets("Sheet1");

    gbid('span1').innerText = excel_sheet.Cells(1191,1).Value;  
    gbid('span2').innerText = excel_sheet.Cells(1192,1).Value;  
    gbid('span3').innerText = excel_sheet.Cells(1192,3).Value;  

    excel_file.Close()
    excel.Quit()
}

每当javascript运行(onload)时,它都会在taskmanager / Processes中创建一个进程。问题是使用后不会关闭它。当我再次运行它,它创建另一个。现在它只是从一个excel文件中提取信息,这个文件正常工作,但是不要在任务管理器中关闭exe文件。我认为 excel_file.close 会做到这一点,我甚至把另外一个, excel.quit ,以防万一。对不起,我只想确保它有效。现在我甚至拿了一个,以防冲突,但纳达。任何帮助?

Whenever the javascript runs (onload) it creates a process in the taskmanager/Processes. The problem is that it wont close it after use. When I run it again, it creates another one. Right now it's just pulling info from an excel file which is working just fine, but it just wont close the exe file in the taskmanager. I thought that excel_file.close would do it and I even put in another one, excel.quit, just in case. Sorry, I just wanted to make sure it worked. I've even taken one away now just in case of conflict but nada. Any help?

推荐答案

您需要调用 excel.Application.Quit(); 而不是 excel.Quit();

这篇关于从JavaScript关闭Excel ActiveX对象会在内存中留下excel.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆