Quantcast
Channel: SCN : Document List - SAP Crystal Reports, version for Visual Studio
Viewing all articles
Browse latest Browse all 52

WPF Project Using the Crystal Reports WPF Viewer in 8 Easy Steps

$
0
0

Purpose

 

This document describes how to create a WPF project using the SAP Crystal Reports WPF viewer.

 

 

Overview

 

By the end of this document, the reader should have a simple working WPF application using the SAP Crystal Reports WPF Viewer. The application uses three lines of code to load a saved data report and display the report in the WPF viewer.

 

 

 

The Project Steps

 

          1. Create a new WPF application in Visual Studio .NET

 

          1.png

 

          2. Set the project to use the full .NET 4.x Framework.

 

          3. Add the SAP Crystal Reports WPF viewer to the Visual Studio Toolbox.

 

          2.png

 

          The viewer should show up in the Visual Studio Toolbox as this icon:

 

          3.png

 

          4. Check that the following references are added to the project:

 

 

               CrystalDecisions.CrystalReports.Engine.dll

               CrystalDecisions.Shared.dll

               CrystalDecisions.ReportSource.dll

               SAPBusinessObjects.WPF.Viewer.dll  ( WPFCRViewer.dll )

               SAPBusinessObjects.WPF.ViewerShared  ( WPFCRViewerShared.dl )

 

               If some of the above references are missing, add these as a new reference

 

          4.png

 

 

 

          5. Add the following decelerations to the project:

 

               Imports CrystalDecisions.CrystalReports.Engine

               Imports CrystalDecisions.Shared

               Imports CrystalDecisions.ReportSource

 

 

          6. Drag the Crystal Reports WPF Viewer from the Toolbox to the form.

               Note(!):  in VS 2013 you must name the viewer component:


          5.png

 

          7. Add code that loads a saved data report and displays it in the WPF Viewer to the MainWindow.xaml.VB form:

 

          Dim crReportDocument AsNew CrystalDecisions.CrystalReports.Engine.ReportDocument

          crReportDocument.Load("C:\tests\formulas.rpt")

          CrystalReportsViewer1.ViewerCore.ReportSource = crReportDocument

 

             The full project code should look like this:

 

          ClassMainWindow

 

             PublicSubNew()

 

                  ' This call is required by the designer.

                   InitializeComponent()

 

                  ' Add any initialization after the InitializeComponent() call.

                   Dim crReportDocument AsNew CrystalDecisions.CrystalReports.Engine.ReportDocument                                      crReportDocument.Load("C:\tests\formulas.rpt")

                   CrystalReportsViewer1.ViewerCore.ReportSource = crReportDocument

              EndSub

 

          EndClass

 

  

          8. To add database logon information, parameters, etc., follow normal programming procedures for Crystal Reports.

 

 

Troubleshooting

 

          1. The MainWindow.xaml file should look like this:

 

               <Window

                        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

                        xmlns:Viewer="clr-namespace:SAPBusinessObjects.WPF.Viewer;assembly=SAPBusinessObjects.WPF.Viewer" x:Class="MainWindow"

                        Title="MainWindow" Height="350" Width="525">

                        <Grid>

                              <Viewer:CrystalReportsViewer x:Name="CrystalReportsViewer1" HorizontalAlignment="Left" Margin="-14,0,0,0" VerticalAlignment="Top" Height="209" Width="531"/>

                        </Grid>

               </Window>

 

          2. Make sure you are using Crystal Reports assemblies of version 13.0.2000.0.

 

          3. Make sure to update your install to Service Pack 9. This is an absolute requirement for Visual Studio 2013.

 

 

  

Follow us on Twitter

 

 

Related Content

 

 

Related Documents

 

Demo: New Crystal Reports for Visual Studio 2010 WPF Viewer

SAP Crystal Reports .NET SDK Developer Guide

SAP Crystal Reports .NET API Guide

Crystal Reports for .NET SDK Samples

Crystal Report Viewer in WPF: Part 1

 

Related Notes (KBAs)

 

KBA: 1639004 - Load Assembly error when using ADO .NET datasets and Crystal Reports WPF viewer

KBA: 1528504 - Introduction to the new Crystal Reports for Visual Studio 2010 WPF Viewer

KBA: 1957717 - How to "clear" the Crystal Reports WPF and viewer

KBA: 1638199 - How to hide the Side Panel of the Crystal Reports WPF viewer?

KBA: 1728139 - Visual Studio .NET WPF viewer displays completely black

KBA: 1836384 - How to automatically adjust the page size of the report of the WPF viewer (fit page)


Viewing all articles
Browse latest Browse all 52

Trending Articles