How to output to excel.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hiye, i've got some data which i've query from the db and how do i get it into ms excel
any body done this before?
 
follow these steps.. get data into dataset/datareader
bind it to datagrid and render the control.

DataSet dsData = (DataSet) Session[PRISMWebConstants.REPORT_DATASET_KEY];
DataView dvData = new DataView(dsData.Tables[0]);
dvData.Sort = "Column ASC";

DataGrid dgTemp = new DataGrid();
dgTemp.DataSource = dvData;
dgTemp.DataBind();

StringWriter swData = new StringWriter();
HtmlTextWriter htmlTWData = new HtmlTextWriter(swData);

dgTemp.RenderControl(htmlTWData);
Response.Write(swData.ToString());
Response.End();

Av.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top