Search code examples
asp.net-mvc-3devexpressxtrareport

Render DevExpress XtraReport template as HTML


We are using DevExpress DX.10.2. Our client has asked to be able to view the XtraReport templates (not the report itself, just the template) within an MVC 3 application that we maintain for them.

My first thought was that I'd have to fake the data to look like the "template" and show the actual reports. However, I noticed in Visual Studio that the XtraReport designer has an "HTML View" option that renders the template in HTML.

I would think that if DevExpress is able to render the template as HTML in the designer then it's likely that there's a way to extract that HTML to render on a view. Is there a way to extract HTML from an XtraReport template?

Thanks!


Solution

  • Stumbled across the solution. Had to add a reference to DevExpress.XtraReports.Web and then the following line writes the report HTML to the response stream:

    XtraReport1 report = new XtraReport1();
    DevExpress.XtraReports.Web.ReportViewer.WriteHtmlTo(System.Web.HttpContext.Current.Response, report);