/// <summary> /// When the process closes, close Excel with it. /// </summary> /// <param name="sender">sender</param> /// <param name="e">event</param> private void OnExit(object sender, EventArgs e) { if (reportWriter != null) { reportWriter.CloseExcel(); } DestroyAllExcel(); }