Getting Started: SharpShooter Report.WPF


SharpShooter Reports.WPF

Getting Started


Table of Content

Preface

System Requirements

Downloading

Installation

Licensing

Developing

Step 1. Applications Creation

Step 2. Add Report Template to the Project

Step 3. Add References

Step 4. Add XAML Code

Step 5. Create and Fill Data Sources

Step 6. Edit Report Template

Step 7. Design Report

Step 8. View Report


Preface

This user guide contains instructions on how to create templates of the simple reports using SharpShooter Reports.WPF.

This user guide is prepared by Perpetuum Software team for SharpShooter Reports.WPF users.

System Requirements

To successfully use SharpShooter Reports.WPF you will need: 

  • .NET Framework 4.0
  • Visual Studio 2010

Downloading

You can download the product on the page: http://www.perpetuumsoft.com/Downloads.aspx

If you purchased the license, then to download the license key, you should enter our site under your account.




Then proceed to the “Downloads” section. 



Find the license key for the product in the products’ list.






Installation

After you downloaded the license key, run the [ProductName].msi file (for example SharpShooterCollection.msi). To install it you need administrative rights.



At the “Additional Options” stage select the following options:

  • Copy dlls to GAC;
  • Add components to Visual Studio Toolbox. It is possible to change the list of displayed elements on Toolbox after you install the component into Visual Studio.


Licensing 

If you have the license, launch the License Manager from the Start menu to install the license. 



To add the license press the “Add from file” button, and select the *. elic which you downloaded. Press the “Close” button to close License Manager.



If you don’t have the license, then there will appear “Trial” pop-ups during the work with the Perpetuum Software components.



There will be shown watermark during the work in the viewer designer.



Developing

Step 1. Applications Creation

Open Visual Studio. Create a new WPF Application project (use .NET Framework 4). 



If you use Client Profile as a default framework, then change it for the full version of framework in the project’s properties.




Step 2. Adding Report Template to the Report

Add a new Item – SharpShooter Reports Template to the project.

 



Step 3. Adding References

Add references to the following assemblies to the project:

  • PerpetuumSoft.Charts
  • PerpetuumSoft.Framework
  • PerpetuumSoft.Framework.Export
  • PerpetuumSoft.Framework.Model
  • PerpetuumSoft.Instrumentation
  • PerpetuumSoft.Reporting
  • PerpetuumSoft.Reporting.Export.Excel
  • PerpetuumSoft.Reporting.Export.Html
  • PerpetuumSoft.Reporting.Export.OpenXML
  • PerpetuumSoft.Reporting.Export.Pdf
  • PerpetuumSoft.Reporting.Export.Rtf
  • PerpetuumSoft.Reporting.Export.Xps
  • PerpetuumSoft.Reporting.WPF
  • PerpetuumSoft.Reporting.Xaml.Export

Step 4. Adding XAML Code

Add the following code (highlighted with yellow) to MainWindow.xaml:

<Window x:Class="WPFSample.MainWindow"
        xmlns:reports="clr-namespace:PerpetuumSoft.Reporting.WPF;assembly=PerpetuumSoft.Reporting.WPF"
        Title="ReportViewer" Height="auto" Width="auto">
    <Grid>
        <reports:ReportViewer x:Name="reportViewer">
            <reports:ReportViewer.Source>
                <reports:ReportSource x:Name="reportSource" Source="c:\Projects\WPFSample\WPFSample\ReportTemplate1.rst">
                </reports:ReportSource>
            </reports:ReportViewer.Source>
        </reports:ReportViewer>   
    </Grid>
</Window>

A direct path to the file is used as Source. You can copy it from the corresponding properties field of the template file. 



Step 5. Creating and Filling Data Sources

Use a List of Business Objects as a data source. Add a new Employee class to the project. The class has the following structure:

internal class Employee
        {
           public string FirstName { get; set; }
            public string LastName { get; set; }
            public string Title { get; set; }
            public string Phone { get; set; }
            public DateTime BirthDate { get; set; }
            public string Address { get; set; }
             }

Fill the collection of products and add the Data Source collection to reportSource (for example, in the Loaded form event handler)

 List<Employee> employeeList = new List<Employee>();
employeeList.Add(new Employee()
{
FirstName = "Maria",
LastName = "Anders"
Title = "Sales Representative",
Phone = "(71)555-5598",
BirthDate = new DateTime(1960, 5, 29),
Address = "Obere str. 57"
});
employeeList.Add(new Employee()
{
FirstName = "Ana",
LastName = "Trujillo",
Title = "Owner",
Phone = "(5)555-4729",
BirthDate = new DateTime(1971, 7, 1),
Address = "Avda. de la Constitution 222"
});
employeeList.Add(new Employee()
{
FirstName = "Antonio",
LastName = "Moreno",
Title = "Owner",
Phone = "(5)555-3932",
BirthDate = new DateTime(1969, 3, 12),
Address = "Mataderos 2312"
});
reportSource.DataSources.Add("EmployeeList", employeeList):
reportViewer.RenderDocument();



Step 6. Editing Report Template

You need to edit the report. It is possible to do this in runtime or design time. It is more convenient to edit the report template in runtime.



Add ability to edit the template in runtime to the application. Put the Design Template button on the form. Add the following handler to this button’s click event:

private void designTemplate_Click(object sender, RoutedEventArgs e)
        {
            reportSource.DesignTemplate();
            reportViewer.RenderDocument();
        }

 

If you want to edit the report template in design time, then double click by the corresponding Item in Solution Explorer.



 

Step 7. Designing Report

Run the application and press the Design Template button. You can select the program language in the designer:CSharp, Visual Basic or custom language. Select the needed one in the ScriptLanguage property of the Document. CSharp is used in this example.

In this example the report is created with Table Wizard to simplify the process of report creation. Click the Table button on the Insert tab. Select Data source in the opened Table Wizard.



Select FirstName, LastName, Phone and Address as Selected fields. Click Next >. Use the default fields’ settings, click Next >. Specify sorting by LastName and FirstName. Click Finish.



After this you can edit the table according your needs. For example, you can change the text alignment, highlight title, etc.:



Step 8. Viewing Report

Save the template and close the designer. The report you created is displayed in ReportViewer.



If you don’t want your end users to edit the template, you can remove the Design Template button and change ReportSource.Source to the resource path (the added templates have Resource type by default): 


<reports:ReportViewer x:Name="reportViewer" Grid.Row="1">
            <reports:ReportViewer.Source>
                <reports:ReportSource x:Name="reportSource" Source="/WPFSample;component/ReportTemplate1.rst"/>
            </reports:ReportViewer.Source>
        </reports:ReportViewer>

If you have any questions regarding the integration with SharpShooter Reports.WPF don’t hesitate to contact us at support@perpetuumsoft.com 


Add Feedback