Hi Friends,
I am generating a report using sql server reporting service and
rendering it in my .aspx page in a report viewer control. Now i need
to export it to excel so that the excel file can be stored in client
pc.How do i show an save as dialoge box,so that user can either
save,open or cancel.
Please help me out.
Thanks,
RanjanOn Feb 27, 12:26 am, "Ranj" <ranjan.raghaven...@.gmail.com> wrote:
> Hi Friends,
> I am generating a report using sql server reporting service and
> rendering it in my .aspx page in a report viewer control. Now i need
> to export it to excel so that the excel file can be stored in client
> pc.How do i show an save as dialoge box,so that user can either
> save,open or cancel.
> Please help me out.
> Thanks,
> Ranjan
You should be able to use something like the following (basically,
call a header):
------
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=" +
Session["SpecialName"].ToString() + "NameOfExcelSpreadsheet.xls");
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
this.ObjectName.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
------
I'm not certain this will work in the Report Viewer itself though. You
might need to add a button/etc to accomplish this outside the report
viewer. Hope this helps.
Regards,
Enrique Martinez
Sr. ASP.NET/SQL Server Developer
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment