日期:2014-05-17 浏览次数:20914 次
/// <summary>
/// 预关闭未退出的Excel进程方法
/// </summary>
public void PreExitExcel()
{
System.Diagnostics.Process[] allProcess = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process thisprocess in allProcess)
{
string processName = thisprocess.ProcessName;
if (processName.ToLower() == "excel")
{
try
{
thisprocess.Kill();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
return;
}
}
}
}