private void btnExcel_Click(object sender, EventArgs e) { ReportWriter reporter = new ReportWriter(); String msg = ""; using (SaveFileDialog sfd = new SaveFileDialog()) { sfd.Filter = "Excel Files | *.xls"; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (sfd.FileName != "" && sfd.FileName.EndsWith(".xls")) { reporter.CreateSummaryReport(summaries, sfd.FileName, out msg); if (msg != "Excel Report Saved") { MessageBox.Show(msg, "Report Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(msg, "Report", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } }