In this article, we'll take a look at the world of the .NET platform in Windows 11 without using Microsoft Visual Studio and create a report that can be exported to PDF. The analog of Visual Studio is, of course, JetBrains Rider. It is a cross-platform .NET IDE developed by JetBrains. It supports C#, VB.NET, and F# languages.
We are not going to discuss here which IDE is better or worse. So, let's just create, build, and export a PDF report/document from JetBrains Rider using FastReport .NET.
What do you need to get started? At least, you need to have the JetBrains Rider IDE installed on your PC. Next, create a new solution by selecting "New Solution".
The next step is to set up the project. Select the Desktop Application project type in the .NET/ .NET Core section. Then we give a name to the project, we will use "ReportPDF_Core_WinFormsApp" as an example. After we click on the Windows Forms App type, C# language, NET 7.0 framework.
Let's start by adding a simple sample dataset for our report in our application code. To do this, add in Form1.cs:
Next, add a private field of the Form1 class:
Let's add a private CreateDataSet method, where we will create and fill in a data set:
Add a call to the CreateDataSet method:
What is the fastest way to make FastReport .NET work in JetBrains Rider? To use our Fast Reports Private NuGet-server.
This article describes how to add NuGet packages after purchasing FastReport .NET. Here is a brief instruction so you don’t need to search for another article. Click on the NuGet tab at the bottom of the IDE, and click on the Sources tab.
Now we add a new repository by clicking on the "+" and entering the necessary data:
- Name — source name without spaces (for example FR-Nuget);
- URL — https://nuget.fast-report.com/api/v3/index.json;
- User — email from Fast Reports account;
- Password — password from Fast Reports account.
You will see the corresponding repository:
Now we will install the FastReport.Pro package. To do this, go to the Packages tab and filter the packages by the FR-Nuget repository. Of course, install the found package.
If it was successful, you will see a notification.
Next add to Form1.cs:
Next, we will insert 3 new buttons into the application: "Report design", "Export to PDF with dialog", "Silent export". To do this, make the appropriate changes to Form1.Designer.cs:
Let's write a click handler for the "Report design" button using this code.
Run the application and look at our form with 3 buttons.
Click on the "Report design" button and go to the FastReport .NET designer.
Let's add fields from the dataset to the report template using drag and drop, and then add the "Employees" heading to the report. After that, set AutoWidth = true property for the text objects.
Let's save our report template with the "Report" name in the folder with the ReportPDF_Core_WinFormsApp project. After saving, close the designer and application. Let's uncomment the line in the btnExportWithDialog_Click method to make our saved report load when the designer is opened:
Add a click handler for the "Export to PDF" button with a dialog box:
Run the project and click on the "Export to PDF with dialog box" button:
A dialog box with PDF export settings will open. Select "Open after export" and click on "OK". Save to a PDF project folder called "Report". After the export is completed, the PDF file will open automatically:
Thus, we got a simple report/PDF document built from a dataset.
Let’s also check the option of the so-called “silent” PDF export without dialog boxes. Add a click handler for the "Silent export" button:
Run the project and click on the "Silent export" button. It will export instantly and a PDF file called "Result" will open, which is next to the exe of the running project:
In this article, we have reviewed the pull of JetBrains Rider (C#) + .NET Core + WinForms + FastReport .NET + Windows 11 and received a PDF report built from a dataset. And of course, we made sure that it is easy to use the .NET platform without Microsoft Visual Studio.