为什么openfiledialog导致excel被添加到任务pipe理器进程?

为什么这会导致excel的发生?

OpenFileDialog openFileDialog1 = new OpenFileDialog(); DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog. if (result == DialogResult.OK) // Test result. { //EXCEL.EXE *32 is now showing in the task manager! 

我正在从openfiledialogselect一个XLSX文件,如上所示,我看到任务pipe理器中的进程。

有人可以告诉我这怎么可能?

如果Excel已经打开,您应该尝试获取此实例,而不是创build一个新实例。

 using System.Runtime.InteropServices; ... Excel.Application xl = null; try { // Try to get an existing instance xl = (Excel.Application)Marshal.GetActiveObject("Excel.Application"); } catch (COMException ex) { // Excel was not open. Open a new instance xl = new Excel.ApplicationClass(); }