none
Report Data export to excel. RRS feed

  • Question

  •  How to export Report data in Report Viewer to excel from custom asp.net button click. I am using Visual Studio 2013.


    Ravindranath

    Tuesday, July 4, 2017 10:42 AM

All replies

  • Hey Ravindranath, this should be pretty straight forward to do. In the click event of your button you can do something similar to the following to Render the report to a byte stream and then write it to the HttpResponse output:

            byte[] reportBytes = this.ReportViewer1.ServerReport.Render("EXCELOPENXML");
    
            this.Response.Clear();
            this.Response.Buffer = true;
            this.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            this.Response.AddHeader("content-disposition", @"attachment;filename=""report.xlsx""");
            this.Response.BinaryWrite(reportBytes);
            this.Response.End();
    Let me know if this doesn't work for you. Thanks!

    Friday, July 7, 2017 12:08 AM
    Moderator