November 26, 2024
Installing FastReport on .NET 8.0 and Creating a Simple Report
Introduction
What is FastReport .NET?
FastReport is a flexible and powerful reporting tool. It allows users to access data sources in various formats and present them visually. Reports created with FastReport can be easily designed using drag-and-drop logic in the user interface and converted to different formats (PDF, Excel, Word, etc.).
FastReport's Role in Reporting Solutions
Reporting is a critical need in data-driven applications. FastReport allows users to visualize and analyze their data. Suitable for both desktop and web applications, this tool provides fast results with minimal coding.
Advantages of Integration with .NET
FastReport works perfectly with .NET applications. When integrated with the powerful development ecosystem offered by .NET, report creation processes can be automated, dynamic reports can be generated, and large data sets can be processed quickly. Additionally, using the flexibility offered by .NET, it is easy to integrate reports with the rest of your application.
Purpose of the Blog
This article aims to explain step by step how to install FastReport on .NET 8.0 and how to create a simple report. Taking the reporting process from the beginning, it will show how to connect, design, and view reports.
1. FastReport Installation
1.1. Requirements
Before you begin, you need to make sure the following requirements are met:
.NET 8.0 Requirements: Make sure your project is running on .NET 8.0 platform. To install .NET SDK, download the latest version from Microsoft's official site.
IDE: You may be using Visual Studio, JetBrains Rider, or another IDE. Check that .NET 8.0 support is enabled in Visual Studio.
1.2. Adding the FastReport NuGet Package
The easiest way to add FastReport to a project is to use the NuGet package manager.
NuGet Package Manager with Visual Studio:
Right-click on your project and select Manage NuGet Packages.
Type FastReport in the search box and select the FastReport.OpenSource package from the results.
Click the Install button and wait until the package installation is completed.
Command Line Installation: If you prefer the command line, you can add FastReport to the project with the following command:
Install-Package FastReport.OpenSource
This will include the latest version of FastReport in your project.
1.3. Licensing and Activation
To start using FastReport, it is important to follow the licensing steps correctly:
Free Version: Although the free version of FastReport offers some basic reporting features, the full version is required for more advanced features.
Licensing: If you want to use the full version, you can purchase a license from FastReport. After you receive the license key, you can activate the program by entering your license key from the FastReport activation window.
Note: The free version has some limitations, for example, the full list of export formats may not be available.
Replacing part of the report content with the text "Demo version" randomly.
The label "Demo version" on the report pages when printing and exporting.
Since I will explain the reporting tool using the trial version in this article, I downloaded the program from the FastReport installation link.
You can proceed directly as the welcome screen provides convenience for automatic installation.
Once the user agreement is approved, you can continue the process.
Here we mark which type of source we will use. For this article, I will only use .NET Trial.
After the installation is completed, the application is ready to use.
1.4 FastReport.OpenSource
FastReport is renowned for its powerful, professional-grade reporting tools and offers two main options based on users' needs: a commercial version and FastReport.OpenSource. FastReport.OpenSource is an ideal choice for developers seeking a fast, cost-free, and customizable reporting solution in small to medium-scale projects. Its open-source nature grants users complete control over the code, enabling them to make in-depth customizations tailored to specific project requirements.
FastReport.OpenSource includes many core functions of reporting tools: it allows you to design reports, create data connections, visualize data, and generate report outputs efficiently and quickly. For small-scale projects or budget-constrained initiatives, its open-source format offers access to powerful reporting capabilities without licensing fees. Additionally, its community-driven structure provides developers with a continuously growing pool of resources and up-to-date knowledge.
1.5 Customization and Development Capabilities
With FastReport.OpenSource’s open-source structure, developers can create tailored customizations suited to their projects. This flexibility allows you to build custom report formats or make specific adjustments to existing features. The ability to customize gives developers the advantage of aligning reports with the functional and visual requirements of their projects.
1.6 Community Support and Resources
One of the key advantages of FastReport.OpenSource is its strong community support. Along with the source code accessible on GitHub, users share their experiences and developments, creating a constant flow of insights. Community support is highly beneficial for troubleshooting and generating new ideas. FastReport’s development team also provides regular updates, ensuring the platform continues to evolve.
1.7 Use Cases
FastReport.OpenSource is an excellent solution for educational projects, personal applications, or startup projects. It is particularly suitable for projects that require essential reporting capabilities, such as financial statements, customer reports, inventory lists, and analysis reports. Its open-source nature makes it fully customizable and adaptable to meet the needs of your specific project.
2. Creating a Simple Report
2.1. Using FastReport Designer
FastReport Designer is a visual tool that simplifies report design.
Introduction to FastReport Designer Interface: FastReport Designer provides a drag-and-drop user interface to design your report. You can easily add components such as data tables, charts, text boxes, etc. to your report.
Adding Data Sources: As a first step, you need to add the data sources that you will connect to your report. These sources can be in various formats, such as SQL databases, JSON files, XML format, etc. In FastReport Designer, you can easily define these data sources and include them in your report.
After opening a blank report design, you can connect your database here by selecting New Data Source from the Actions box.
FastReport does not require us to use only MS SQL. If you wish, you can define your data in formats such as JSON and XML and create your reports.
You can flexibly use all the options in your database during import. In addition to tables, procedures and views can also be imported into FastReport and used in reports.
2.2. Report Layout Design
Creating a Simple Table Report: When you start designing a report, you can use the table component to show your data. In this sample application, I will create a simple report using information such as age, name, etc. in a table containing company personnel.
Adding Headers, Data Fields, and Footers: Make your report more readable by adding header rows to the table. Connect data fields with data from the data source. You can add additional information such as totals and page numbers to the footer rows.
Style and Formatting Options: You can use style and formatting options to make your report look more visually professional. For example, you can make headings bold and change the color of data cells.
In a simple design, after adding the data source, the entire report can be created by adding only text. In the modal where the texts to be added are opened, there are System Variables and Data Source variables for convenience. By selecting these, the entire report can be created with the drag-and-drop feature.
2.3. Preview the Report
Running the Report and Viewing it in Preview Mode: After you design your report, you can run it in preview mode to see if the design looks right. In this mode, you can view your report in different formats and fix any errors.
You can see a preview of the report you are working on via File-Preview or Report-Preview.
Exporting the Report in Different Formats: FastReport allows you to export reports in different formats such as PDF, Excel, and Word. You can use the “Save” button in preview mode to convert your report to the desired format.
3. .NET Code Integration and Calling the Report from the Application
3.1. Calling a Report with a DB Connection
After saving the report we just created as .frx, we can transfer it to our .net project as a file and call the report from this file. In reports prepared with a mssql db connection, you must install the "FastReport.Data.Mssql" package.
We are ready to call the report we just prepared from the project. We save our frx file via FastReport and add it to our “BasicFastReportDotnet8” project, which we opened as a .net8 console app.
The packages we will use in this operation are:
FastReport
FastReport.Data
FastReport.Export.Image
Let's open our .frx extension file and take a look;
In fact, we can almost update the report from here. The elements we use in the file are presented in XML format and our data source connections are nicely defined. Great!
Now, since we used mssql connection in this report, we need to go and specify it:
In this way, we indicate that the report has ready data and there is no need for a preparation process. The rest is child's play!
First, create a new report instance and create our report object.
Then load the frx file prepared into the relevant report.
Give the command to prepare the report.
And finally, decide in which format we will save it.
Yep, that's all!
Let's see how our report turned out:
3.2. Calling Simple Report Template by Feeding Data from Application
These operations can also be performed using an empty template. We can repeat the same operation with the desired objects by giving the "report.RegisterData" command to the report object just before the prepared operation.
Conclusion
Fast and Efficient Reporting with FastReport
FastReport offers a fast and effective reporting solution for both small projects and large-scale applications. Thanks to its user-friendly interface and .NET integration, report design and management can be easily performed. In addition, being able to pull records from the DB at any time increases the speed of report analysis by separating server-side and DB operations.
Advantages of FastReport
Seamless integration with .NET applications, multiple data source support, and flexible design options make FastReport an attractive choice.
Advice on Exploring Advanced Features
To explore FastReport’s advanced features, you can browse its official documentation and work with templates, charts, and more complex reporting techniques.
Using a Private NuGet Server
If you’re using the commercial version of FastReport, you can set up a private NuGet server to access FastReport packages specifically for internal or private projects. This method is especially useful for corporate users who need to maintain control over access management and updates. The flexibility FastReport offers allows you to access NuGet packages in a more secure and manageable way.
For more details, refer to the Private NuGet Server Setup article.
The article is written by Liubou Patskevich from Softacom.