Export cellset grid report

Posted by Rajarbind under ASP.NET on 4/22/2008 | Views : 2758 | Status : [Member] | Replies : 1
Hi Narayana,
I am using cellsetgrid control .CellSetGrid is a simple asp.net control for browsing Analysis Services 2005 cubes. I want to export the data into excel file.Please help me regarding coding.
Regards,
Arbind.




Responses

Posted by: Poster on: 4/22/2008 [Member] Starter

Up
0
Down
I have following code to export a GridView to Excel, you can get some clue from it.


protected void ExportToExcel(object sender, EventArgs e)
{

string attachment = "attachment; filename=myExcelSheet_" + DateTime.Now.ToString() + ".xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
// hide private columns if any
GridView1.Columns[0].Visible = false;
GridView1.Columns[12].Visible = false;
GridView1.Columns[19].Visible = false;

GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();

}


In place of GridView1, you can write your cellsetgrid id.

:)

Rajarbind, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response