Export To Excel
-
dear all i want to create a export button in my site by which all the record for the registered user stored in user table will exports into an excel file. how could i do taht help me for the same. i was created my site in C# language. With regards Yogesh Agarwal
-
dear all i want to create a export button in my site by which all the record for the registered user stored in user table will exports into an excel file. how could i do taht help me for the same. i was created my site in C# language. With regards Yogesh Agarwal
You need to show data's need to be exported on a DataGrid. Say Datagrid1. Set the page response content type to excel. Using HTMLTextWriter to render the grid and write that to response. See the following code
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
this.EnableViewState =false;
System.IO.StringWriter ObjTextWriter= new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter ObjHTMLWriter= new System.Web.UI.HtmlTextWriter(ObjTextWriter);
Datagrid1.RenderControl(ObjHTMLWriter);Hope this helps
-
dear all i want to create a export button in my site by which all the record for the registered user stored in user table will exports into an excel file. how could i do taht help me for the same. i was created my site in C# language. With regards Yogesh Agarwal
-
dear all i want to create a export button in my site by which all the record for the registered user stored in user table will exports into an excel file. how could i do taht help me for the same. i was created my site in C# language. With regards Yogesh Agarwal
ReportDocument rpt=new ReportDocument(); rpt.Load(Server.MapPath("ReqVsCur.rpt")); rpt.SetDatabaseLogon("username","password"); rpt.SetParameterValue("@year",DateTime.Now.Year); MemoryStream oStream; oStream=(MemoryStream)rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel); Response.Clear(); Response.Buffer=true; Response.ContentType="application/vnd.msexcel"; Response.BinaryWrite(oStream.ToArray()); Response.End();