Skip to main content Skip to footer

Loading Rdl Reports in C1WpfReportViewer

ReportViewer for WPF can only display HTML and PDF-based reports. If we want to display RDL reports in it there is no directly available method. This blog will discuss the usable approach for displaying RDL reports in WPF ReportViewer. First, we need to create an object C1RDLReport and load any RDL report in it. The code will look like:

 C1RdlReport rdlrpt = new C1RdlReport();  

But WPF ReportViewer only displays HTML and PDF-based reports and C1RdlReport does not have a method or property that exports its report in PDF or HTML. Hence, we will create an object of C1PrintDocument which will work as intermediator between the two. Then we will use its Export method to pass the report into a memory stream with the help of PdfExportProvider. Here is the code for the same:

 C1PrintDocument pdoc = rdlrpt.C1Document;  
 var ms = new MemoryStream();  
 pdoc.Export(ms, C1.C1Preview.Export.ExportProviders.PdfExportProvider);

Finally, we need to display this memory stream in the WPF ReportViewer. This can be done by the following code:

 ms.Seek(0, SeekOrigin.Begin);  

A complete sample implementing the same is enclosed. Download Sample


comments powered by Disqus