How to generate a report from an ASP.NET Core application using FastReport.Core.Skia

How to generate a report from an ASP.NET Core application using FastReport.Core.Skia

Previously, we told you how to generate a report from an ASP.NET Core application, but not all users use Windows OS or the GDI+ graphics engine (due to unstable operation). Especially for these users, we have developed a special version of FastReport.Core, which uses Skia as a graphics engine and its wrapper for .NET - SkiaSharp. Full package name— FastReport.Core.Skia. The FastReport.Core.Skia and FastReport.Web.Skia packages are available on our private NuGet server.

The main advantages of FastReport.Core.Skia include:

You can also learn more about the benefits of FastReport.Skia in this article.

Creating a report and application on Windows

The process of creating a report will be simple. We need to create a report in the designer and run it in an ASP.NET Core application. As an example, we use the standard and familiar template “Simple List.”

Selecting a standard report template

At this stage, we have a ready-made template. Now it needs to be displayed on the Web Preview via the ASP.NET Core application. Let's start creating the application.

Creating ASP.NET Core applications

 

Selecting advanced options

As a result, we successfully created the project. The next step is to add the necessary nuget packages, namely FastReport.Core.Skia and FastReport.Web.Skia. This article uses a method for connecting packages from a private NuGet server.

Connecting packages from a private NuGet server

The necessary packages have been installed. Now let's connect FastReport in the Program.cs file.

var builder = WebApplication.CreateBuilder(args);

app.UseFastReport();

app.Run();

The next step is to edit the Index() method in HomeController.cs. 

public IActionResult Index()
 {
 var report = new WebReport();
 var data = new DataSet();
 data.ReadXml($"C:/Users/User/Documents/nwind.xml"); 
 report.Report.RegisterData(data);
 report.Report.Load($"C:/Users/User/Documents/Simple List.frx");
 ViewBag.WebReport = report;
 return View();
 }

Now we need to configure the view. To do this, you need to leave the following code in the index.cshtml file.

@await ViewBag.WebReport.Render()

Our application is ready! We can run it and look at the result.

Ready report

As you may have noticed, creating a project is almost no different compared to the FastReport.Core package. All you have to do is download another NuGet package.

 

Creating a report and application on Linux

Let's now create an ASP project on Linux and display the report in it.

Attention! Make sure that you have downloaded the necessary packages for your .NET projects to work and installed at least VSCode. Also, you need to configure VSCode itself, namely installing an extension for C# and connecting a private NuGet server.

After downloading .NET and installing VSCode, we create a project. The next step is to connect the NuGet packages FastReport.CoreSkia and FastReport.Web.Skia. Unlike Windows, we will also need 2 other Skia packages: SkiaSharp.NativeAssets.Linux and HarfBuzzSharp.NativeAssets.Linux. This is what the list of installed NuGet packages should look like.

List of installed NuGet packages

The packages have been installed, now let's run the project. To get started, enter the command:

dotnet build

Then enter the following command:

dotnet run

Running commands to work with a project

Follow the local link and check the report in the browser.

Ready report in the browser

The process of creating a project using FastReport.Core.Skia is quite simple and, to some extent, “traditional.” We just need to connect additional packages for Linux. In return, you get an improved display of some texts and characters from Eastern languages in exports that you may have encountered when using GDI+. Also, we recommend using the Skia rendering engine if you are a Linux user.

Fast Reports
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314

© 1998-2024 Fast Reports Inc.
Trustpilot