protected void btnExportXLS_Click(object sender, EventArgs e) { if (Page.IsValid) { try { string fileName = string.Format("customers_{0}.xls", DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")); string filePath = string.Format("{0}files\\ExportImport\\{1}", HttpContext.Current.Request.PhysicalApplicationPath, fileName); CustomerCollection customers = GetCustomers(); ExportManager.ExportCustomersToXLS(filePath, customers); CommonHelper.WriteResponseXLS(filePath, fileName); } catch (Exception exc) { ProcessException(exc); } } }