public void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "Excel File|*.xls|Excel File|*.xlsx";
openFileDialog1.ShowDialog();
string path = openFileDialog1.FileName;
comboBox1.Items.Clear();
Microsoft.Office.Interop.Excel.Application xlr = new
Microsoft.Office.Interop.Excel.Application();
Workbook wb = xlr.Workbooks.Open(path, 0, false, 5, "", "", false,
XlPlatform.xlWindows, "", true, false, 0, true, false, false);
foreach (Worksheet w in xlr.Worksheets)
{
comboBox1.Items.Add(w.Name);
}
xlr.Visible = true;
wb.Close();
xlr.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(wb);
System.Runtime.InteropServices.Marshal.ReleaseComObject(xlr);
}
How can i safely dispose off/Release Excel COM objects in the above code??
Even after releasing in the above fashion i see that excel is running in the task manager under processes ...?