Quick Start with SharpShooter Reports.Web using NuGet (ASP.NET MVC)

Table of Contents

System Requirements
Introduction
Implementation
Step 1. Add SharpShooter Reports.Web package to your project
Step 2. Add the Report Viewer to the ViewStep
Step 3. Run the ProjectStep
Step 4. Edit the Report

System Requirements

In order to successfully use SharpShooter Reports.Web in ASP.NET MVC Web applications you need: 

  • .NET Framework 4 and higher
  • Visual Studio 2010 and higher
  • ASP.NET MVC 4 and higher

Introduction

This document describes how to add SharpShooter Reports.Web reporting functionality into your ASP.NET MVC3 Application (with Razor view engine). We imply that you already have a ready ASP.NET MVC 3 application and need to add reporting functionality there.

Also we imply that you already have NuGet extension installed in your Visual Studio. If you don’t have it please install the extension as described here.

Following this tutorial, you will be able to configure a service and add a report viewer with a predefined skin into your web-application in 10 minutes using the NuGet package.

Implementation

Step 1. Add SharpShooter Reports.Web package to your project

Note: Before installing the package into your project, please make sure that you have SharpShooter Reports.Web installed on your machine.

Open context menu of your project and select the "Manage NuGet Packages…" option.


 
Select the "Online" option in the left sidebar and enter SharpShooter.Reports in the search string.
Select SharpShooter Reports.Web (ASP.NET MVC 3+Razor) from the available packages and press the Install button.


 
This package will add the following items to your project:
  • JavaScript files to /Scripts/SharpShooterReports
  • Report Controller /Controllers/SharpShooterReports/SharpShooterReportServiceController.cs
  • Report Service files to /Controllers/SharpShooterReports/SharpShooterReportService
  • Shared View /Views/Shared/SharpShooterReportViewer/_SharpShooterReportViewer.cshtml
  • Images and CSS to /Content/SharpShooterReports 

Step 2. Add the Report Viewer to the View

Open the _Layout.cshtml file


 
And add the following line to the header section:

@RenderSection("ReportViewerHeader"false);

Add a Controller to the project and name it "Reports". Add the View for this controller.

Open the newly created View and add the following code:
@section ReportViewerHeader 
{
<link href="@Url.Content("~/Content/SharpShooterReports/ReportViewer.css")" rel="stylesheet" type="text/css" />
<
link href="@Url.Content("~/Content/SharpShooterReports/WebViewerSkin.css")" rel="stylesheet" type="text/css" />
}
@{Html.RenderPartial("SharpShooterReportViewer/_SharpShooterReportViewer");}


Step 3. Run the Project

Run the application and go to the “reports” Controller.

Note: In some cases you may face an error which is shown on the screen below. In order to fix it remove the Perpetuumsoft.Framework reference from the project and add it manually.  
 
After the report is loaded you will see the following:

Step 4. Edit the Report

In order to edit report find
/Controllers/SharpShooterReports/SharpShooterReportService/SharpShooterReportsServiceClass.cs, and select View Designer from the context menu. You will see something like this:


 
Double click the ReportManager 1 component, select the InlineReportSlot1 item and press the Run Designer button.


 
The report designer will be opened and you will be able to edit the report according to the documentation.

If you have any questions regarding the integration with SharpShooter Reports.Web don’t hesitate to contact us.

Add Feedback