WPF ReportDocument类型的报表查看器不起作用

问题描述 投票:0回答:1

[我试图在VS2017中的WPF应用中显示报告文件。 CS1代码可以完美工作并要求连接数据。在CS2中,我想通过ReportDocument做到这一点,但是我只等待带有灰色背景的Wheel,而Viewer不需要输入连接数据。知道怎么做吗?我需要使用CS2方法。

CS1:

cryrep.ViewerCore.ReportSource = "C:\\Reports\\GeneralBusiness\\testDB.rpt";
cryrep.ViewerCore.RefreshReport();

CS2:

CrystalDecisions.CrystalReports.Engine.ReportDocument crReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
crReportDocument.Load("C:\\Reports\\GeneralBusiness\\testDB.rpt", CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy);

cryrep.ViewerCore.ReportSource = crReportDocument;
cryrep.ViewerCore.RefreshReport();

我的XAML:

<UserControl
x:Class="ReportingPortal.Views.ReportingPortalFilterView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="clr-namespace:UCM.Infrastructure.Behaviors;assembly=UCM.Infrastructure"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cr="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer"
xmlns:lex="http://wpflocalizeextension.codeplex.com"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
lex:LocalizeDictionary.DesignCulture="de"
lex:ResxLocalizationProvider.DefaultAssembly="ReportingPortal"
lex:ResxLocalizationProvider.DefaultDictionary="Resources"
prism:ViewModelLocator.AutoWireViewModel="True"
KeyboardNavigation.TabNavigation="Cycle"
mc:Ignorable="d">
<Grid Background="{DynamicResource LightLightBaseColorBrush}">

    <cr:CrystalReportsViewer
        x:Name="cryrep"
        Width="1000"
        Height="1600"
        Margin="-14,0,0,0"
        HorizontalAlignment="Left"
        VerticalAlignment="Top" />

</Grid>

c# wpf report reportviewer
1个回答
0
投票

我必须安装CrforVS Runtime,现在可以正常运行

© www.soinside.com 2019 - 2024. All rights reserved.