Quantcast
Channel: ASP.NET – TechnoBlogy
Viewing all articles
Browse latest Browse all 20

Easy way to Export dataset in Excel

$
0
0

Fastest way to export dataset in excel format is:

DataSet dsExport = new DataSet();

System.IO.StringWriter tw = new System.IO.StringWriter();

HTMLTextWriter hw = new HTMLTextWriter(tw);

DataGrid dg = new DataGrid();

dg.DataSource = "Dataset to be exported"

hw.WriteLine ("<b><font size=’3′>Exported report</font></b>");

dg.DataBind();

Response.ContentType = "application/vnd.ms-excel";

EnableViewState = false;

Response.Write(tw.ToString());

Response.End();


Viewing all articles
Browse latest Browse all 20

Trending Articles