简体   繁体   中英

Report Viewer in WPF?

I want to add a report viewer (just like crystal report viewer) in my WPF project. Here I find a link to do this. But this is done by windowsForm Control Hosting. I want to add a report viewer without hosting a winFom Control.

I believe crystal reports (SAP, actually) has a WPF version of their viewer. It can be used with the following code (as an example):

<Window x:Class="WpfCrystalReport.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:my="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=
                                                                               SAPBusinessObjects.WPF.Viewer"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <my:CrystalReportsViewer HorizontalAlignment="Left" Name="crystalReportsViewer1"
                                 VerticalAlignment="Top" Height="500" Width="500" />
    </Grid>
</Window> 

You need to be sure to reference "SAPBusinessObjects.WPF.Viewer.dll" and also reference "SAPBusinessObjects.WPF.ViewerShared.dll". I am guessing that these are normally downloaded with the crystal reports development version.

Note - If you need a full tutorial, as of this answer, you can find more information at C-Sharp Corner here . The second page of the article is where they actually create the report and add it to the form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM