matlab excel 进程,Matlab使用xlsread, xlswrite函数导致excel进程无法终止的问题

系统版本:Win7 64位

Matlab版本:R2015b

问题描述:使用excel的操作函数,比如xlsread,xlswrite,导致excel进程无法终止,任务管理器中仍残留excel进程,打开excel文档,修改后不提示保存。

20180110171933906286.png

进程显示automation -Embedding,应该是某个应用占用了这个进行,然后我并没有找到是哪个应用。

解决方法:

之前的老版本Matlab R2012a并没有出现此问题,问题是在R2015b版本中的%Program Files%MATLAB\R2015b\toolbox\matlab\iofun\+matlab\+io\+internal\getExcelInstance.m文件,代码:

1 function app =getExcelInstance2 % Copyright 2015The MathWorks, Inc.3

4 persistent excelApplication;5 if isempty(excelApplication) || ~isactive ||excelApplication.Visible6 % If Excel is not available, this will throwan exception. If7 %Excel has been made visible, we assume the user opened the8 % worksheet outside MATLAB usingthe same Excel process, and so we9 % should start a newprocess.10 excelApplication = actxserver(‘Excel.Application‘);11 end12 app =excelApplication;13

14 function tf =isactive15 % Try accessing a readonly property of the COM server to see if it is

16 %active.17 try

18 get(excelApplication, ‘Version‘);19 tf = true;20 catch

21 excelApplication.delete;22 excelApplication =[];23 tf = false;24 end25 end26 end

第四行的关键词persistent,如果直接换成excelApplication=[],则不会出现进程残留的情况;

这个文件应该是R2015b版本中加上去的,之前的版本excel操作函数是直接调用actxserver函数,也没有出现此问题;

后续打算卸载R2015b版本,换成R2015a版本试试;

原文:http://www.cnblogs.com/jmpep/p/5015343.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值