For reporting I create an excel application, export some data to it, and make it visible for the user.
public void MyMethod()
{
Excel.Application excelApp = new Excel.Application();
object misValue = System.Reflection.Missing.Value;
Excel.Workbook workBook = excelApp.Workbooks.Add(misValue);
Excel.Worksheet workSheet = (Excel.Worksheet)workBook.Worksheets.get_Item(1);
Excel.Range range;
//my export code here..
//at last excel application is shown for user
excelApp.Visible = true;
}
When the user clicks the "Close" button, a dialog appears that contains ["Save", "Don't save" and "Cancel"]. In any case (save or don't save), the window closes, but the EXCEL.EXE process is live like picture in this question: Like this picture , because I don't close it yet.
How can I define if the user closes the viewed excel window or not? If yes, then I will quit that excel application which I created.
Edit: I need something like "Exit event". To define if user close window, to Quit application.