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