Export to excel
Code .NET SQL :: ASP.NET :: C# :: Import / Export data
Page 1 sur 1
Export to excel
- Code:
protected void ExportToExcel(object sender, EventArgs e)
{
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
Response.AddHeader("content-disposition", "attachment;filename=" + "export.xls");
Response.ContentType = "application/vnd.xls";
GridViewTimingPart.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
Si Masterpage
protected void ImageButtonExportExcel_Click(object sender, ImageClickEventArgs e)
{
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
Response.AddHeader("content-disposition", "attachment;filename=" + "export.xls");
Response.ContentType = "application/vnd.xls";
HtmlForm frm = new HtmlForm();
this.Controls.Add(frm);
frm.Controls.Add(tableData);
frm.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
Code .NET SQL :: ASP.NET :: C# :: Import / Export data
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum