logo
small logo
  • Produkte
  • Shop
  • Support
  • Über uns
  • Customer panel Support
    • en
    • de
    • JP
    • ZH
  • Home
  • /
  • Articles
  • /
  • How to use the FastReport.Core library from nuget
  • Die Events PreviewControl.OnPrint und PreviewControl.OnExport

    1. Oktober 2020

    FastReport 2019.4 bietet eine Möglichkeit, die Events PreviewControl.OnPrint und PreviewControl.OnExport zu steuern, die direkt aufgerufen

    read more
  • MS Word versus Open Document Text. Was ist besser?

    19. Oktober 2020

    Wenn wir von Texteditoren sprechen, stellen wir uns die Leuchte sofort als Microsoft Word vor,

    read more
  • Wollten Sie Tabellen für den Benutzer generieren - Excel oder OpenOffice Calc?

    8. Oktober 2020

    Tabellen. Seit Jahrhunderten werden sie verwendet, um dieselbe Art von Daten für Buchhaltungszwecke, Zählbeträge und

    read more
  • So organisieren Sie Vererbung der Reporte in FastReport .NET

    29. Januar 2021

    Wenn Sie angewiesen werden, eine große Anzahl von den Reporten innerhalb desselben Unternehmensstils zu erstellen,

    read more
  • Wie schützen Sie Ihr PDF?

    30. November 2020

    Am Vorabend des Datenschutztages haben wir beschlossen, ein Material zum Schutz von PDF-Dokumenten vorzubereiten. PDF-Dokumente

    read more

How to use the FastReport.Core library from nuget

20. Mai 2018

UPD: Applies to the versions of FastReport .NET before 2022.2. License packages are now available on our NuGet server.

One of the innovations of FastReport.NET 2018 was the ability to use NuGet packets FastReport. To install the packages, it was necessary to create a local package source and place the compiled FastReport libraries in it. This mechanism is preserved for licensed packages, but demonstration versions are now available in the general NuGet repository:

https://www.nuget.org/profiles/FastReports

Let's look at the example. Create a .NET Core application. Call the context menu for the solution and select the item Manage NuGet Packages.

Choose Packages source - nuget.org. In the search bar type FastReport.

You need to install both packages: FastReport.Core и FastReport.Web.

The first is the actual FastReport library for the .Net Core framework. And the second one is a WebReport object that allows you to display the report and manage it in the browser.

To display the report in the application, we need a report file. And since the report works with the database, then the database file do so. Let's take from the delivery of FastReport.Net the Master-Detail.frx report template and the nwind.xml database file. Put them in the Reports folder, which you must first create in the root directory of wwwroot:

 

Open the class HomeController.

We need an interface IHostEnviroment, with which you can get information about the environment. Specifically, we need the WebRootPath property to specify the path to the report file and the database. Therefore, we add a constructor of a class that takes as an argument the interface of interest to us.

1
2
3
4
5
private readonly IHostingEnvironment _hostingEnvironment; 
public HomeController(IHostingEnvironment hostingEnvironment)
 {
 _hostingEnvironment = hostingEnvironment;
 }

 And in the Index method, write the following code:

1
2
3
4
5
6
7
8
9
10
11
 public IActionResult Index()
 {
 string webRootPath = _hostingEnvironment.WebRootPath; // Get the path to the wwwroot folder
 WebReport webReport = new WebReport(); // Create a Web Report Object
 webReport.Report.Load(webRootPath + "/reports/Master-Detail.frx"); // Load the report into the WebReport object
 var dataSet = new DataSet(); // Create a data source
 dataSet.ReadXml(webRootPath + "/reports/nwind.xml"); // Open the xml database
 webReport.Report.RegisterData(dataSet, "NorthWind"); // Register the data source in the report
 ViewBag.WebReport = webReport;
 return View();
 }

 To display a WebReport object on a web page, change the Index.cshtml view as follows:

1
2
3
4
@{
 ViewData["Title"] = "Home Page";
}
 @await ViewBag.WebReport.Render();

In the file Startup.cs you also need to make changes - add only one line of code:

1
2
3
4
5
 public void Configure(IApplicationBuilder app, IHostingEnvironment env)
 {
 app.UseFastReport();
 …
}

 Now run the application:

Usege of FastReport.Core is now even easier. However, licensed packages still have to be installed from a local source. Configuring the local source of NuGet packages takes you no more than a minute of time.

about product buy
avatar
Dmitriy Fedyashov
Technical Writer
Fast Reports Team: Dmitriy Fedyashov - Technical Writer at Fast Reports
.NET FastReport

Add comment
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Shop
  • Download
  • Dokumentation
  • Referenzen
  • Informationen zur Deinstallation unserer Produkte
  • FAQ
  • Tutorial Video
  • Forum
  • Support SLA
  • Articles
  • Unsere Nachrichten
  • Presse über uns
  • Partner
  • Außergewöhnliche Lizenzierung
  • Kontakte

© 1998-2023 by Fast Reports Inc.

  • Datenschutz

Trustpilot