ActiveReports 13
Viewing Reports using JS Viewer
ActiveReports 13 > ActiveReports User Guide > Viewing Reports > JS Viewer > Viewing Reports using JS Viewer

JS Viewer communicates with the reporting service through the Web API. To implement the Web API, the GrapeCity.ActiveReports.Aspnet.Viewer.dll (.NET Framework) assembly is used.

The following steps describe how to configure a target ASP.NET backend application.

  1. JS Viewer Web API Server

  2. Open Microsoft Visual Studio 2017 and create a new ASP .NET Web Application project.
  3. Select Empty project template and click OK
  4. In the Menu bar, go to  Tools > NuGet Package Manager >  Package Manager Console.
  5. In the Package Manager Console window, write the following command:
    install-package Microsoft.Owin.Host.SystemWeb –Pre
    Note that following Owin packages are installed:
    • Microsoft.Owin.Host.SystemWeb 4.0.0
    • Microsoft.Owin 4.0.0
  6. Now to add Owin startup class, go to Solution Explorer, right-click the project and select Add > New Item.
  7. In the Add New Item dialog, select OWIN Startup Class.
  8. In Solution Explorer, right-click References and select Add Reference.
  9. In the Reference Manager dialog that appears, click Browse and navigate to ActiveReports 13 folder containing assemblies. By default it is C:\Program Files (x86)\Common Files\GrapeCity\ActiveReports 13 on 64-bit Windows.
  10. Select GrapeCity.ActiveReports.Aspnet.Viewer.dll assembly and click Add. In the Reference Manager dialog, click OK to confirm the added assembly.
  11. Go to C:\Program Files (x86)\GrapeCity\ActiveReports 13\Deployment\JSViewer folder on 64-bit Windows.
  12. Copy the Web.config file and paste it in your project to replace the existing one.
    Note: Remove the <handlers> directive from the Web.config file if the application does not serve its own static files. Keep this handler only if the application serves its own static files similar to the JS Viewer sample's HomeController class.
  13. Add and configure a reporting middleware, for example: 
    Copy Code
    // Startup.cs
    using GrapeCity.ActiveReports.Aspnet.Viewer;              
    public void Configuration(IAppBuilder app)
        app.UseReporting(settings =>
            // Reporting middleware settings
            settings.UseFileStore(new DirectoryInfo("path to the reports folder"));

    Note: Don't forget to configure CORS if you're using a separate backend application.

    JS Viewer Client Application

    The following steps describe how to view reports in the JS Viewer. The steps include adding and initializing the JSViewer on a static HTML page.

    In Solution Explorer, right-click project and select Add > New Item.
  14. Select HTML Page item type, input index.html and click Add.
  15. Create 'scripts' folder in your sample project root.
  16. Go to C:\Program Files (x86)\GrapeCity\ActiveReports 13\Deployment\JSViewer folder.
  17. Copy jsViewer.min.js and jsViewer.min.css files and paste them in the 'scripts' folder.    
  18. In Solution Explorer, find newly-added index.html and modify its content as follows: 
    Paste inside the <head></head> tags
    Copy Code
    <!DOCTYPE html>
        <meta charset="utf-8" />
    <!--Add the references to these files to the target HTML page-->
        <link rel="stylesheet" href="">
        <link rel="stylesheet" href=",300,600,700" type="text/css">
        <link rel="stylesheet" href="scripts/jsViewer.min.css" type="text/css">
        <script src="scripts/jsViewer.min.js"></script>
    <!--Add the DIV element that will contain the JSViewer in the target HTML page-->
        <div class=theme-default id="viewerContainer">Loading Report</div>
    <!--Add the code that initializes and passes the parameters in the JSViewer instance. The code might vary depending on the technology used to develop the JSViewer component. The example of code for the pure javascript component:-->
    <script type="text/javascript">
        var viewer = GrapeCity.ActiveReports.JSViewer.create({
            element: '#viewerContainer',
            reportID: 'ReportName.rdlx', // the id of the report to display
            availableExports: ['Xml', 'Pdf', 'Excel'],
            reportService: {}
            // other properties
  19. Press F5 to run the project. You see a report is deployed in the target web site in JS Viewer:
See Also