protected void btnExcel_Click(object sender, EventArgs e) { try { string print = ""; string appPath = HttpContext.Current.Server.MapPath("~"); string strexcelname = ""; if (appPath != "") { strexcelname = txtexcelname.Text; appPath = appPath.Replace("\\", "/"); if (strexcelname != "") { print = strexcelname; //FpEntry.SaveExcel(appPath + "/Report/" + print + ".xls", FarPoint.Web.Spread.Model.IncludeHeaders.BothCustomOnly); //Print the sheet //ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "alert('" + print + ".xls" + " saved in" + " " + appPath + "/Report" + " successfully')", true); //Aruna on 26feb2013============================ string szPath = appPath + "/Report/"; string szFile = print + ".xls"; // + DateTime.Now.ToString("yyyyMMddHHmmss") FpSpread1.SaveExcel(szPath + szFile, FarPoint.Web.Spread.Model.IncludeHeaders.ColumnHeadersCustomOnly); Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.AddHeader("Content-Disposition", "attachment; filename=" + szFile); Response.ContentType = "application/vnd.ms-excel"; Response.Flush(); Response.WriteFile(szPath + szFile); //============================================= } else { lblnorec.Text = "Please Enter Your Report Name"; lblnorec.Visible = true; } } } catch (Exception ex) { lblnorec.Text = ex.ToString(); } }
protected void btnxl_Click(object sender, EventArgs e) { string appPath = HttpContext.Current.Server.MapPath("~"); string print = ""; if (appPath != "") { int i = 1; appPath = appPath.Replace("\\", "/"); e: try { print = "Consolidated Student GPA And CGPA" + i; //FpSpread1.SaveExcel(appPath + "/Report/" + print + ".xls", FarPoint.Web.Spread.Model.IncludeHeaders.BothCustomOnly); //Aruna on 26feb2013============================ string szPath = appPath + "/Report/"; string szFile = print + ".xls"; // + DateTime.Now.ToString("yyyyMMddHHmmss") FpSpread1.SaveExcel(szPath + szFile, FarPoint.Web.Spread.Model.IncludeHeaders.ColumnHeadersCustomOnly); Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.AddHeader("Content-Disposition", "attachment; filename=" + szFile); Response.ContentType = "application/vnd.ms-excel"; Response.Flush(); Response.WriteFile(szPath + szFile); //============================================= } catch { i++; goto e; } } //ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "alert('" + print + ".xls" + " saved in" + " " + appPath + "/Report" + " successfully')", true); }