Question

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.

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top