One of the advantages that makes Telerik Reporting stand out is its versatility, and specifically its ability to work with variety of technologies. It covers the well-established WebForms, WinForms and WPF platforms as well as modern web paradigms like MVC and Angular 2+. Migrating between these technologies is also a no-hassle process, since Telerik Reporting provides the tools and templates that will do the heavy-lifting for you.
As explained in a previous blog post, reusability is a substantial feature of our product—you create the reports once, using a report designer of your choice, store them in a class library, file storage or a database and then just load them in a report viewer. But configuring a report viewer may also take time, so we went a step further and decided to automate the process of adding a new report viewer to your project, regardless of the selected platform. We used Item templates—the Visual Studio’s common interface for adding and configuring a new item to a project through a wizard.
The item templates that add a new report viewer come in two flavors, for both C# and VB developers. The templates share the same consistent look, but, depending on the selected project type, provide different configuration options and output files.
Initially the user has to select the reporting engine among three options: embedded, REST service or Report server. The “Embedded” option is only available for WinForms and WPF projects, because in these cases the reporting engine works locally—the report processing and rendering are performed by the same application. “REST service” and “Report server” options suggest that the viewer obtains its contents by an external service that can be hosted on another physical machine.
On the next pages, the user is required to configure the report source, providing additional information related with the engine selection. Depending on the selected options, the wizard can traverse the solution structure, looking for report classes, or connect to a Telerik Report Server instance to obtain the list of categories and reports that can be displayed by the new viewer. The wizard can also add a new report or create a new report library project that contains a sample report definition.
After pressing Finish, the wizard has gathered all the necessary information to successfully create and add the new item to the project. Depending on the selected options, a new report library can be added to the solution or a sample report can be included in an existing library. If needed, the wizard can download and install NuGet packages that are required to connect the viewer to a REST service or Report Server. The wizard maintains a detailed log for all the events that occurred during the process and displays it when finished.
When the wizard completes its work successfully, the initially selected project will be set up to work with Telerik Reporting and will have a report viewer, ready to display a report as previously configured. The report viewer can be hosted in a new form, window, cshtml view or an HTML/aspx page, depending on the project type.
The group contains three types of item templates—HTML5 Report Viewer Page, MVC Report Viewer View and WebForms Report Viewer Form, covering the most popular scenarios for presenting reports in a web application. Since the MVC Report Viewer and HTML5 WebForms Report Viewer are actually wrappers around the HTML5 Report Viewer, their item template wizards are similar, but in contrast of WPF and WinForms item templates, they lack the “Embedded” option when selecting the reporting engine. The wizard will automatically add and/or modify the required classes like ReportsController and Global.asax. Finally, the wizard will add a new HTML/aspx page or a cshtml view to the project, leaving to you to decide how and when to display them.
The item template wizards for the so-called “desktop viewers” have the same configuration options, but the former produces a new System.Windows.Forms instance, and the latter a new System.Windows.Window, where the report viewer control is hosted. If the report viewer connects to a REST service or Report Server instance, the wizard will automatically add the NuGet packages to the project or configure them, if they already exist. The project’s startup form or window will not be changed, so the newly added item can be instantiated and shown when needed.
In case of Angular we provide a ready to use package, hosted on the npmjs.com public repository. The package can be included in your project with just one npm command. The report viewer is compatible both with Angular CLI and SystemJS projects, and to further ease the setup, we provide typescript definitions.
We are no stranger to ASP.NET Core too. The HTML5 Report Viewer works flawlessly within ASP.NET Core 1.0+ (including 2.0). To simplify the setup the required Telerik Reporting REST Service can be not only hosted in MVC 4 and 5 applications, but with the provided NuGet packages you can host the REST Service with your ASP.NET Core .NET Framework enabled project.
Regardless of how carefully the item templates are designed and implemented, sometimes errors occur—and it’s crucial to provide detailed information about the problem and how to eliminate it. As mentioned above, the item template wizard displays a summary upon completion, which can be thoroughly examined to find the exact cause of the received error. The log itself is an HTML page that is saved in the selected project’s folder and can be reviewed later.
In this blog I explained how easy it is to add and set up a new report viewer to an existing application, regardless of the target platform, using the item template wizards in Visual Studio. The variety of options ensures that effectively no code is needed to display your reports and the detailed log information helps to quickly troubleshoot any error that might occur.
If you are curious see how Telerik Reporting can save you time and effort, start a free trial of Reporting and Report Server today.
By leveraging the broad array of themes, skins, styling and customization options, your application will awe even the best front-end designers. Check it out!
Ivan Hristov has been a software developer in the Telerik Reporting division since 2013.
When not at work, he might be seen biking/skiing with his daughter, reading or discussing influential movies with friends. Feel free to reach out to him through LinkedIn.