FRNetProgrammerManual en
FRNetProgrammerManual en
NET
Programmers Manual
Version 2022.3
© 2008-2022 Fast Reports Inc.
www.fast-report.com 1 / 118
General information
Installing into VS Toolbox
Troubleshooting
Deployment
Compiling the source code
Credits
www.fast-report.com 2 / 118
Installing into VS Toolbox
To add FastReport .NET components to the Visual Studio toolbox, you need to do the following steps:
delete the "FastReport .NET" tab from the Toolbox, if it is there;
create a new tab (to do this, right-click the Toolbox and select "Add Tab" item), or select an existing tab you
would like to add FastReport components to;
right-click on a tab and select "Choose Items...":
in the dialog, press the "Browse..." button and choose FastReport.dll, FastReport.Web.dll files (they are located
in the "C:\Program Files\FastReports\FastReport.Net" folder);
close the dialog with OK button.
After this, you will see FastReport .NET components in a chosen tab:
Report;
PreviewControl;
DesignerControl;
EnvironmentSettings;
WebReport (this component will be visible in ASP.NET project only).
www.fast-report.com 3 / 118
Troubleshooting
If you face a problem when working with report designer (for example, some toolbars or tool windows are
damaged), you should delete the configuration file. This file is created when you start FastReport .NET. It is located
in the following folder:
Windows XP:
Windows Vista:
C:\Users\user_name\AppData\Local\FastReport\FastReport.config
www.fast-report.com 4 / 118
Deployment
You may redistribute the following files along with your application:
FastReport.dll - the main FastReport .NET library;
FastReport.Web.dll - the library that contains ASP.Net WebReport component;
FastReport.Bars.dll - the toolbars and docking windows library;
FastReport.Editor.dll - the code editor with syntax highlight. This library is not needed if you don't provide an
end-user designer;
FastReport.Compat.dll - the library for cross-platform compatibility;
FastReport.DataVisualization.dll - the library for drawing charts;
FastReport.xml - comments for classes, properties and methods used in FastReport. This file is used by the
script editor, and also by the hint panels in the "Data" and "Properties" windows. It's not obligatory to
distribute this file.
If your reports are stored in files, you have to deploy them as well.
www.fast-report.com 5 / 118
Compiling the source code
Source code is shipped with FastReport .NET Professional edition. It includes source code of FastReport.dll,
FastReport.Web.dll libraries. You may include it in your application's solution file. Let us demonstrate how to do
this:
open your project in the Visual Studio;
open the Solution Explorer and right-click on the "Solution" item;
choose the "Add/Existing Project..." item;
add the "FastReport.csproj" file (it is located in the "C:\Program
Files\FastReports\FastReport.Net\Source\FastReport" folder);
add the "FastReport.Web.csproj" file (it is located in the "C:\Program
Files\FastReports\FastReport.Net\Source\FastReport.Web" folder).
Turn off assembly signing for FastReport and FastReport.Web projects. To do this:
right-click the "FastReport" project in the Solution Explorer;
choose the "Properties" item;
switch to the "Signing" tab and uncheck the "Sign the assembly" checkbox;
do the same steps for FastReport.Web project.
Update the references to other FastReport .NET assemblies. To do this:
expand the "FastReport\References" item in the Solution Explorer;
remove the "FastReport.Bars", "FastReport.Editor" references;
right-click the "References" item and choose the "Add Reference..." item;
add references to the "FastReport.Bars.dll" and "FastReport.Editor.dll" files. These files are located in the
"C:\Program Files\FastReports\FastReport.Net" folder.
www.fast-report.com 6 / 118
Credits
Toolbars and docking - DevComponents (http://www.devcomponents.com)
Code editor with syntax highlight - Quantum Whale (http://www.qwhale.net)
Silk icons set (http://www.famfamfam.com/lab/icons/silk)
www.fast-report.com 7 / 118
Working with Windows.Forms
Using the Report component in Visual Studio
Working with report in a code
Storing and loading a report
Registering data
Passing a value to a report parameter
Running a report
Designing a report
Exporting a report
Configuring the FastReport .NET environment
Replacing the "Open" and "Save" dialogs
Replacing the standard progress window
Passing own connection string
Passing custom SQL
Reference to a report object
Creating a report by using code
Using own preview window
Filtering tables in the Data Wizard
www.fast-report.com 8 / 118
Using the Report component in Visual Studio
Let us consider the typical use of the Report component in Visual Studio. We will use the data from a typed dataset.
create a new Windows Forms application;
add a dataset into it ("Data|Add New Data Source..." menu item);
switch to the Form designer;
add the "DataSet" component on a form and connect it to the typed dataset that you have created.
To create a report, perform the following steps:
put the "Report" component on a form:
right-click it (or click on a smart tag button) and select the "Design Report..." item:
create your report. Read more about this in the User's Manual;
close the report designer;
add a "Button" control on your form;
double-click it and write the following code in the button_Click event handler:
report1.Show();
save the project and run it. When you click on a button you will see the prepared report.
www.fast-report.com 9 / 118
Working with report in a code
To work with Report component in a code, you need to do the following:
create a report instance;
load a report file into it;
register the application-defined data in a report;
pass the values into the report parameters, if needed;
run the report.
The following example demonstrates how to do this:
We will consider these steps in details in the following sections of this manual.
www.fast-report.com 10 / 118
Storing and loading a report
You may store a report in the following ways:
Method Description
in the .FRX This method is useful if you want to give your users
file the ability to change a report. In this case, set the
report's StoreInResources property to false. To load
the report from a file, use the Load method of the
Report object: report1.Load("filename.frx");
as a To work with a report as a class, design your report Options..." menu). Include that file into your
C#/VB.NET and save in to the .cs/.vb file. To do this, select "file project. This method has the following pros and
class type" in the "Save" dialog. The file type maybe either cons:+ you can work with a report as a class;+
.cs or .vb - it depends on the script language in the you may debug a report;+ this is the only way
report (it may be changed in the "Report to use a report in ASP.NET project running on
medium trust environment;- you cannot edit
such a report. To do this, you need the original
.FRX file;- if you need to change a report, you
have to recompile your application.To work
with a report, create an instance of the report's
class:
SimpleListReport report = new
SimpleListReport();
report.Show();
www.fast-report.com 11 / 118
Registering data
If your report uses data from an application (for example, the typed dataset or a business-object), you have to
register such data in a report. This can be done using the RegisterData method of the Report object.
When you use the Report as described in the "Using the Report component in Visual Studio" section, you don't
need to register the data. FastReport .NET does it automatically (it adds the RegisterData call in the
InitializeComponent method of your form).
The RegisterData method must be called after you have loaded the report:
The RegisterData method is overloaded and allows to register the following data:
Method Description
void RegisterData(DataSet Registers the dataset. This method registers all tables, views and relations as
data)
well.Attention: if you register more than one dataset, use the RegisterData(DataSet
data, string name) method instead.
void RegisterData(DataSet Registers the dataset. Specify any name in the name parameter (it must be persistent
data, string name)
and unique if you register more than one dataset).
void Registers the business object. Specify what items (properties, fields) should be used, in
RegisterData(IEnumerable the flags parameter. Specify the maximum nesting level in the maxNestingLevel
data, string name,
BOConverterFlags flags, int parameter (typically you need no more than 3 levels). Several nested objects may slow
maxNestingLevel) down the report.
www.fast-report.com 12 / 118
Passing a value to a report parameter
The report may have parameters. Read more about this in the User's Manual. To pass a value to the parameter, use
the SetParameterValue method of the Report object:
report1.Load("report.frx");
report1.SetParameterValue("MyParam", 10);
report1.Show();
Specify the parameter's name in the complexName parameter. To access a nested parameter, use its full name, for
example:
"ParentParameter.ChildParameter"
www.fast-report.com 13 / 118
Running a report
To run a report, use one of the following methods of the Report object:
Method Description
bool Prepare() Runs a report. If the report was prepared successfully, returns true. After this method, you need
to call one of the following methods: ShowPrepared, PrintPrepared, SavePrepared,
Export:
if (Prepare())
ShowPrepared();
bool Prepare(bool Runs a report. If the append parameter is set to true, the prepared report will be added to the
append)
existing one.
So you can build several reports and display them in the preview as one report:
report1.Load("report1.frx");
report1.Prepare();
report1.Load("report2.frx");
report1.Prepare(true);
report.ShowPrepared();
void ShowPrepared() Shows a prepared report in the preview window. The report must be either prepared using the
Prepare method, or loaded from the .FPX file using the LoadPrepared method:
if (Prepare())
ShowPrepared();
void Shows a prepared report in the preview window. The modal parameter determines whether the
ShowPrepared(bool preview should be shown modally.
modal)
void The same as the previous method. The owner parameter determines a window that owns the
ShowPrepared(bool preview window.
modal, Form owner)
void The same as the previous method. The mdiParent parameter determines the main MDI window.
ShowPrepared(Form
mdiParent)
www.fast-report.com 14 / 118
Designing a report
You can use the report designer in your application. This is possible for all FastReport .NET editions except the
Basic. To do this, use the Design method of Report object:
Method Description
bool Design(bool Shows the designer. The modal parameter determines whether it is necessary to show the
modal) designer modally.
bool Design(Form Shows the designer. The mdiParent parameter defines the main MDI window.
mdiParent)
www.fast-report.com 15 / 118
Exporting a report
The prepared report can be exported to one of the supported formats. At this moment, the following formats can
be used:
PDF
HTML
RTF
Excel XML (Excel 2003+)
Excel 2007
CSV
TXT
OpenOffice Calc
Pictures (Bmp, Png, Jpeg, Gif, Tiff, Metafile)
The export is performed by the export filter. To do this:
prepare a report using the Prepare method;
create an instance of export filter and set up its properties;
call the Export method of the Report object.
The following example exports a prepared report in the HTML format:
// prepare a report
report1.Prepare();
// create an instance of HTML export filter
FastReport.Export.Html.HTMLExport export = new FastReport.Export.Html.HTMLExport();
// show the export options dialog and do the export
if (export.ShowDialog())
report1.Export(export, "result.html");
In this example, export settings are made using the dialog window.
www.fast-report.com 16 / 118
Configuring the FastReport .NET environment
Using the EnvironmentSettings component which is available in the Toolbox, you can control some FastReport .NET
environment settings. To do this, put the component on your form and set up its properties using the Properties
window.
The EnvironmentSettings.ReportSettings property contains some report-related settings:
Property Description
bool Determines whether to show the information about the report performance (report generation time,
ShowPerformance
memory consumed) in the lower right corner of the preview window.
Property Description
Property Description
PreviewButtons Buttons Set of buttons that will be visible in the preview's toolbar.
int PagesInCache The number of prepared pages that can be stored in the memory cache during preview.
bool ShowInTaskbar Determines whether the preview window is displayed in the Windows taskbar.
bool TopMost Determines whether the preview window should be displayed as a topmost form.
string Text The text for the preview window. If no text is set, the default text "Preview" will be used.
The EnvironmentSettings.EmailSettings property contains email account settings. These settings are used in the
"Send Email" feature in the preview window:
Property Description
www.fast-report.com 17 / 118
Property Description
string MessageTemplate The message template that will be used to create a new message. For example, "Hello, Best
regards, ...".
string UserName, string User name and password. Leave these properties empty if your server does not require
Password authentication.
bool AllowUI Allows to change these settings in the "Send Email" dialog. Settings will be stored in the
FastReport .NET configuration file.
Property Description
UIStyle UIStyle The style of designer and preview form. 6 styles are available - VisualStudio2005, Office2003,
Office2007Blue, Office2007Silver, Office2007Black, VistaGlass. The default style is Office2007Black.
bool This property affects the designer and preview form. It determines whether the Office2007-style
UseOffice2007Form
form should be used if one of the following styles is selected: Office2007Blue, Office2007Silver,
Office2007Black, VistaGlass.Default value is true.
Besides these properties, the EnvironmentSettings component has some events. Using such events, you may do the
following:
replace standard "Open file" and "Save file" dialogs in the designer;
replace standard progress window;
pass own connection string to a connection defined in the report.
These tasks will be described in the following sections of this manual.
www.fast-report.com 18 / 118
Replacing the "Open" and "Save" dialogs
If you decided to store a report in the database, you may need to change the designer in such a way that it can
open and save reports from/to a database. That is, you need to replace standard "Open" and "Save" dialogs with
your own dialogs that work with database. To do this, use the EnvironmentSettings component (see the
Configuring the FastReport .NET environment). This component has the following events:
Event CustomOpenDialog
Occurs when the report designer is about to show the "Open" dialog. In the event handler, you must display a
dialog window to allow user to choose a report file. If dialog was executed successfully, you must return e.Cancel =
false and set the e.FileName to the selected file name. The following example demonstrates how to use this event:
Event CustomSaveDialog
Occurs when the report designer is about to show the "Save" dialog. In the event handler, you must display a dialog
window to allow user to choose a report file. If dialog was executed successfully, you must return e.Cancel = false
and set the e.FileName to the selected file name. The following example demonstrates how to use this event:
Event CustomOpenReport
Occurs when the report designer is about to load the report. In the event handler, you must load the report
specified in the e.Report property from the location specified in the e.FileName property. The latter property
contains the name that was returned by the CustomOpenDialog event handler. It may be the file name, the
database key value, etc. The following example demonstrates how to use this event:
www.fast-report.com 19 / 118
private void CustomOpenReport_Handler(object sender, OpenSaveReportEventArgs e)
{
// load the report from the given e.FileName
e.Report.Load(e.FileName);
}
Event CustomSaveReport
Occurs when the report designer is about to save the report. In the event handler, you must save the report
specified in the e.Report property to the location specified in the e.FileName property. The latter property contains
the name that was returned by the CustomSaveDialog event handler. It may be the file name, the database key
value, etc. The following example demonstrates how to use this event:
www.fast-report.com 20 / 118
Replacing the standard progress window
The progress window is shown during the following actions:
running a report
printing
exporting
You may turn off the progress by setting the ReportSettings.ShowProgress property of the EnvironmentSettings
component to false. Besides that, you may replace the standard progress window with your own. To do this, use the
following events of the EnvironmentSettings component (see the "Configuring the FastReport .NET environment"
section):
Event Description
StartProgress Occurs once before the operation. In this event, you have to create your own progress window and
show it.
Progress Occurs each time when current report page is handled. In this event, you have to show the progress
state in your window.
FinishProgress Occurs once after the operation. In this event, you have to destroy the progress window.
The Progress event takes e parameter of ProgressEventArgs type. It has the following properties:
Property Description
int Total The number of total pages in a report. This parameter may be 0 when preparing a report, because the
number of total pages is unknown.
In most cases, you need to display the text from the e.Message property, in the Progress event handler. Other
parameters may be useful if you want to display a progress bar.
www.fast-report.com 21 / 118
Passing own connection string
If you use data sources that are defined inside a report, you may need to pass an application-defined connection
string to a report. This can be done in three ways.
The first method: you pass a connection string directly to the Connection object in a report. Do the following:
report1.Load(...);
// do it after loading the report, before running it
// assume we have one connection in the report
report1.Dictionary.Connections[0].ConnectionString = my_connection_string;
report1.Show();
The second method: you pass a connection string using the report parameter. Do the following:
run the report designer;
in the "Data" window, create a new report parameter (with "MyParameter" name, for example). See the User's
Manual for more details;
in the "Data" window, select the "Connection" object that contains a data source;
switch to the "Properties" window and set the ConnectionStringExpression property to the following:
[MyParameter]
report1.SetParameterValue("MyParameter", my_connection_string);
The third method: use the DatabaseLogin event of the EnvironmentSettings component (see the "Configuring the
FastReport .NET environment" section). This event occurs each time when FastReport opens the connection. Here is
an example of this event handler:
Keep in mind that the DatabaseLogin event is global, it works with all reports.
www.fast-report.com 22 / 118
Passing custom SQL
The report may contain data sources that are added using the Data Wizard (via "Data|Add Data Source..." menu).
Sometimes it is needed to pass custom SQL to that data source from your application. To do this, use the following
code:
using FastReport.Data;
report1.Load(...);
// do it after loading the report, before running it
// find the table by its alias
TableDataSource table = report1.GetDataSource("MyTable") as TableDataSource;
table.SelectCommand = "new SQL text";
report1.Show();
www.fast-report.com 23 / 118
Reference to a report object
When you work with a report as a class (see the "Storing a report and loading it" section), you may refer to the
report objects directly. The following example demonstrates how to change the font of the "Text1" object contained
in a report:
In other cases, you have to use the FindObject method of the Report object, if you need to get a reference to an
object:
To reference to a data source defined in a report, use the GetDataSource method of the Report object. This method
takes a data source's alias as a parameter:
DataSourceBase ds = report1.GetDataSource("Products");
www.fast-report.com 24 / 118
Creating a report by using code
Let us consider how to create a report in code. We will create the following report:
// create DataBand
DataBand data1 = new DataBand();
data1.Name = "Data1";
data1.Height = Units.Centimeters * 0.5f;
// set bounds
text1.Bounds = new RectangleF(0, 0, Units.Centimeters * 19, Units.Centimeters * 1);
// set text
text1.Text = "PRODUCTS";
// set appearance
text1.HorzAlign = HorzAlign.Center;
text1.Font = new Font("Tahoma", 14, FontStyle.Bold);
// add it to ReportTitle
page1.ReportTitle.Objects.Add(text1);
// group
TextObject text2 = new TextObject();
text2.Name = "Text2";
text2.Bounds = new RectangleF(0, 0, Units.Centimeters * 2, Units.Centimeters * 1);
text2.Text = "[[Products.ProductName].Substring(0, 1)]";
text2.Font = new Font("Tahoma", 10, FontStyle.Bold);
// add it to GroupHeader
group1.Objects.Add(text2);
// data band
TextObject text3 = new TextObject();
text3.Name = "Text3";
text3.Bounds = new RectangleF(0, 0, Units.Centimeters * 10, Units.Centimeters * 0.5f);
text3.Text = "[Products.ProductName]";
text3.Font = new Font("Tahoma", 8);
// add it to DataBand
data1.Objects.Add(text3);
// group footer
TextObject text4 = new TextObject();
text4.Name = "Text4";
text4.Bounds = new RectangleF(0, 0, Units.Centimeters * 10, Units.Centimeters * 0.5f);
text4.Text = "Count: [CountOfProducts]";
text4.Font = new Font("Tahoma", 8, FontStyle.Bold);
// add it to GroupFooter
group1.GroupFooter.Objects.Add(text4);
// add a total
Total groupTotal = new Total();
groupTotal.Name = "CountOfProducts";
groupTotal.TotalType = TotalType.Count;
groupTotal.Evaluator = data1;
groupTotal.PrintOn = group1.Footer;
www.fast-report.com 26 / 118
www.fast-report.com 27 / 118
Using own preview window
Using the EnvironmentSettings component (see the "Configuring the FastReport .NET environment" section), you
may tune up the standard preview window. The related properties are contained inside the
EnvironmentSettings.PreviewSettings property.
If you don't want to use the standard preview window for some reason, you may create your own. To do this, use
the PreviewControl control that can be added on your form. To show a report in this control, connect it to the
Report object by the following code:
report1.Preview = previewControl1;
To prepare a report and show it in the PreviewControl, use the Show method of the Report object:
report1.Show();
your_form.ShowDialog();
if (report1.Prepare())
{
report1.ShowPrepared();
your_form.ShowDialog();
}
In these examples, the your_form is your form that contains the PreviewControl.
Using the methods of PreviewControl component, you can handle it from your code. You may even turn off the
standard toolbar and/or statusbar, using the ToolbarVisible, StatusbarVisible properties. This is demonstrated in the
Demos\C#\CustomPreview example project.
www.fast-report.com 28 / 118
Filtering tables in the Data Wizard
The Data Wizard can be called from the "Data|Add Data Source..." menu. Here you can set up the connection and
choose one or several data tables. By default, the wizard displays all tables available in the selected connection. If
you want to filter unnecessary tables, use the Config.DesignerSettings.FilterConnectionTables event. The following
example shows how to remove the "Table 1" table from the tables list:
using FastReport.Utils;
Config.DesignerSettings.FilterConnectionTables += FilterConnectionTables;
private void FilterConnectionTables(
object sender, FilterConnectionTablesEventArgs e)
{
if (e.TableName == "Table 1")
e.Skip = true;
}
www.fast-report.com 29 / 118
Working with ASP.NET
Using the WebReport component
Setting up web handler
Storing and loading a report
Registering data
Passing a value to a report parameter
Working in the "Medium Trust" mode
Working in Web Farm and Web Garden architectures
Working with ASP.NET MVC
Example of export in MVC
FastReport .Net and jQuery
www.fast-report.com 30 / 118
Using the WebReport component
Let us consider the typical case of using the WebReport component.
assuming that you have a web project with all necessary data sources (for example, AccessDataSource);
put the WebReport component on your web form:
in the "smart tag" menu, select the "Select Data Source..." item and choose one or several data sources which
you want to use in a report:
in the "smart tag" menu, select the "Design Report..." item to run the report designer:
www.fast-report.com 31 / 118
Setting up web handler
WebReport requires a specific handler to be set in the web.config file. When you create a report object in Visual
Studio, necessary lines are automatically written to the configuration file. The WebReport component checks the
availability of the specified configuration at run time of the application. If the required lines are not found in the
web.config file an error is thrown, requesting the file to be changed.
The web.config file should contain the following lines when used with an IIS6 server:
<system.web>
…
<httpHandlers>
<add path="FastReport.Export.axd" verb="*" type="FastReport.Web.Handlers.WebExport"/>
</httpHandlers>
…
</system.web>
<system.webServer>
…
<handlers>
<add name="FastReportHandler" path="FastReport.Export.axd" verb="*"
type="FastReport.Web.Handlers.WebExport"/>
</handlers>
…
</system.webServer>
The correct WebReport configuration lines in the web.config file must be used when transferring your project from
one server to another.
Check for correct working of the WebReport handler by means of the URL:
http://yoursite/app_folder/FastReport.Export.axd
An information message gives the version of FastReport and the server time.
www.fast-report.com 32 / 118
Storing and loading a report
You may store a report in the following ways:
In a web form:
Typical scenario that we have looked at before, uses this method. The report is stored in the ReportResourceString
property of the WebReport component. This method has the following pros and cons:
+ it's a simplest way to work with FastReport.Net;
- the report template is stored in the ViewState of your web form. It will be transferred on a client side. It may slow
down the work if the report has a big size;
- this method is not compatible with "Medium Trust" mode.
The report loading is performed automatically.
In the .FRX file:
This method assumes that the report is stored in a file in a special folder "App_Data". To do this:
- run the report designer;
- create a report and save it to the .FRX file;
- in the Solution Explorer, select the "App_Data" folder, right-click it and choose the "Add/Existing Item..." item.
Select the report file that you just saved;
- select the WebReport component and clear its ReportResourceString property;
- select the "ReportFile" property, invoke its editor and choose the report from "App_Data" folder.
This method has the following pros and cons:
+ the report is not transferred to a client machine;
- this method is not compatible with "Medium Trust" mode.
The report loading is performed automatically.
A report can also be loaded from WebReport.StartReport event handler. Example code in StartReport:
(sender as WebReport).Report.Load(this.Server.MapPath("~/App_Data/report.frx"));
As a C#/VB.NET class:
In this method, you work with the report as a class. To do this:
- design your report and save in to the .cs/.vb file. To do this, select "file type" in the "Save" dialog. The file type
maybe either .cs or .vb - it depends on the script language in the report (it may be changed in the
"Report/Options..." menu);
- include that file into your project. It's better to save it in the "App_Code" folder;
- clear both ReportResourceString and ReportFile properties of the WebReport component.
This method has the following pros and cons:
+ you can work with the report as a regular class;
+ you can debug the report in the Visual Studio;
+ it's the only way to use a report in the "Medium Trust" mode;
- you cannot edit such a report. To do this, you need the original .FRX file.
www.fast-report.com 33 / 118
To work with a report, create the WebReport.StartReport event handler. In this handler, you should do the
following:
- create an instance of your report class;
- register the data;
- set the report to the Report property of the WebReport component.
Example of the StartReport event handler:
The prepared report can be displayed from WebReport.StartReport event handler using the property
WebReport.ReportDone. Example code in StartReport to load and display a prepared report:
(sender as WebReport).Report.LoadPrepared(this.Server.MapPath("~/App_Data/Prepared.fpx"));
(sender as WebReport).ReportDone = true;
www.fast-report.com 34 / 118
Registering data
If you select the data source using the "smart tag" menu of the WebReport component, you don't need to register
the data manually. In this case, FastReport.Net stores the names of data sources in the ReportDataSources property
of the WebReport component.
In case you don't want to use such method of registering data, you need to do it manually. It can be done by using
the StartReport event of the WebReport component. In this event handler, you can call the RegisterData and
RegisterDataAsp methods of the report. The report can be accessed through the WebReport.Report property:
webReport1.Report.RegisterData(myDataSet);
www.fast-report.com 35 / 118
Passing a value to a report parameter
To pass a value to the report parameter, use the SetParameterValue method of the Report object. This method was
described in details in the "Working with Windows.Forms" chapter.
To use this method in ASP.NET, you need to create the event handler for the StartReport event of the WebReport
component. The report can be accessed through the WebReport.Report property:
webReport1.Report.SetParameterValue("MyParam", 10);
www.fast-report.com 36 / 118
Working in the "Medium Trust" mode
This mode is used by many shared hosting providers. In this mode, the following actions are restricted:
report compilation is impossible;
impossible to use MS Access data source;
impossible to use the RichObject;
impossible to use some export filters that use WinAPI calls or temp files (PDF, Open Office);
there may be other restrictions, depending on the provider.
To work with a report in this mode, you need to store a report as a C#/VB.NET class, as described in the "Storing
and loading a report" section. In this case, the report compilation is not required.
Besides that, it is necessary to add System.Windows.Forms.DataVisualization.dll assembly into the GAC. This
assembly is a part of Microsoft Chart Control and is used in FastReport to draw charts. Consult with your shared-
hosting provider regarding adding this assembly into the GAC.
www.fast-report.com 37 / 118
Working in Web Farm and Web Garden architectures
To use the FastReport report generator in a multi-server (Web Farm) or multi-processor (Web Garden) architecture
there are additional requirements for creating special storage for data synchronization between WebReport
objects.
Add the following lines to the configuration file web.config:
<appSettings>
<add key="FastReportStoragePath" value="\\FS\WebReport_Exchange"/>
<add key="FastReportStorageTimeout" value="10"/>
<add key="FastReportStorageCleanup" value="1"/>
</appSettings>
FastReportStoragePath : path to the folder for temporary files when working in a multi-server architecture,
each server must have access to this folder
FastReportStorageTimeout : cache time for reports, in minutes
FastReportStorageCleanup : time for checking the expired cache entries, in minutes
Check for correct configuration by means of the URL:
http://yoursite/app_folder/FastReport.Export.axd
You should see "Cluster mode: ON".
www.fast-report.com 38 / 118
Working with ASP.NEТ MVC
You will not have any problems when using WebReport in ASPX (MVC 2) – it is only necessary to drag the control
from the Toolbox to the page. WebReport will make all the required changes to web.config automatically. Let's look
at a demo of WebReport in aspx, to be found in folder \Demos\C#\MvcDemo.
To use WebReport in Razor (MVC 3,4) you will need to add a line with the handler definitions to the web.config file
in the root folder of your web-application.
Add this line in section <system.web> for use with IIS6:
and add this line in section <system.webServer> for use with IIS7:
Then modify the web.config file in the folder containing Views. Add these lines in section
<system.web.webPages.razor> :
@WebReportGlobals.Scripts()
@WebReportGlobals.Styles()
Now you can draw the report on the View. Go to the controller and create a WebReport:
@ViewBag.WebReport.GetHtml()
Similar code to create WebReport you can also write directly in View.
Let's look at the demo of WebReport in Razor in folder \Demos\C#\MvcRazor. There are various samples for
loading into the report, including pre-prepared, and there is an example of using the event StartReport.
using FastReport.Export.Pdf;
// load report
webReport.ReportFile = this.Server.MapPath("~/App_Data/report.frx");
// prepare report
webReport.Report.Prepare();
// save file in stream
Stream stream = new MemoryStream();
webReport.Report.Export(new PDFExport(), stream);
stream.Position = 0;
// return stream in browser
return File(stream, "application/zip", "report.pdf");
}
using FastReport.Export.OoXML;
...
webReport.Report.Export(new Excel2007Export(), stream);
...
return File(stream, "application/xlsx", "report.xlsx");
www.fast-report.com 40 / 118
FastReport .Net and jQuery
The WebReport object from FastReport.Net uses the jQuery library. You may already be using this library in your
project.
To avoid duplication of jQuery boot scripts and styles in the client browser when working with markup Razor, you
must use the following lines in _Layout.cshtml:
@WebReportGlobals.ScriptsWOjQuery()
@WebReportGlobals.StylesWOjQuery()
@WebReportGlobals.Scripts()
@WebReportGlobals.Styles()
You must set the property ExternalJquery = true (defaults to false) when working with ASPX markup.
www.fast-report.com 41 / 118
Working with WCF
WCF service library FastReport.Service.dll
Simple example of WCF service
Creating Web Service using FastReport.Service.dll
Creating the WCF service hosted in windows service
www.fast-report.com 42 / 118
WCF service library FastReport.Service.dll
FastReport .NET contains the library FastReport.Service.dll (only in the .NET 4.0 package). This library is a WCF
Service Library and is intended for use in custom applications that perform the functions of the service.
List<ReportItem> GetReportsList();
returns a list of available reports. Each item is returned as a ReportItem object. Reports are stored on a hard drive
on a server that is running the service. Files are sorted in alphabetical order.
returns a list of available reports by path. Files are sorted in alphabetical order.
List<GearItem> GetGearList();
returns a list of available formats that can generate service reports as elements GearItem.
Stream GetReport(ReportItem report, GearItem gear);
returns a stream of the result of building a report. Parameters "report" and "gear" can be used from the lists
previously obtained, or by creating new objects with the required properties. The returned stream does not support
positioning.
Let's look at list elements.
ReportItem
Path – path to the report file on the server, relative to the root folder for storing reports. The file extension of the
report must be *.frx. This property is used to identify a specific report with further queries.
www.fast-report.com 43 / 118
Name – name of the report, taken from the metadata of the report. If the metadata of the report contains an empty
name then the property contains a filename without an extension. This property can be used to build an interactive
list of available reports in your application (eg: in a ListBox).
Description – description of the report, taken from the metadata of the report.
Dictionary<string, string> Parameters – dictionary of report parameters, may be filling parameters, which will be
subsequently transferred to the report. It supports only the string values that must be considered when designing a
report template.
GearItem
Name – name of the format : may contain one of the following strings:
Name Description
MHT Compressed HTML file together with the images, can be opened in Internet Explorer
www.fast-report.com 44 / 118
<appSettings>
<add key="FastReport.ReportsPath" value="C:\Program files\FastReports\FastReport.Net\Demos\WCF" />
<add key="FastReport.ConnectionStringName" value="FastReportDemo" />
<add key="FastReport.Gear" value="PDF,DOCX,XLSX,PPTX,RTF,ODS,ODT,MHT,CSV,DBF,XML,TXT,FPX" />
</appSettings>
FastReport.ReportsPath – specifies the path to the folder with the reports, a list of which will be transmitted to the
client.
FastReport.ConnectionStringName – name of the connection string to the database, which is stored in the
configuration section . Used to replace the internal connection string in the report template.
FastReport.Gear – list of available formats. You can select only those required and change the order of the names.
Schematic of using FastReport.Service:
And, if you already know exactly what to report and in which format to receive it (this reduces the number of
queries made to the service):
Important points to note when you create report templates for use in the services:
dialogs in the reports are not supported and will be ignored;
each report must include an internal DataConnection, whose connection string for the report service is
replaced by a string from the configuration.
Examples of use of FastReport.Service.dll can be found in the folders \Demos\C#\WCFWebService ,
\Demos\C#\WCFWindowsService , \Demos\C#\WCFWebClient , \Demos\C#\WCFClient.
An example configuration file service - FastReport.Service.dll.config.
www.fast-report.com 45 / 118
Simple example of WCF service
This example does not require programming and is intended for testing the library and the configuration file. To
complete the task, we will use the program WcfSvcHost.exe, that comes with Visual Studio:
1. Create a folder for our project anywhere on the disk, eg: as C:\WCF\FastReport
2. Copy these files to the folder : FastReport.Service.dll, FastReport.Service.dll.config, FastReport.dll and
FastReport.Bars.dll
3. Create two sub-folders \Data and \Reports
4. Copy the database file to the \Data folder from the Demos folder \FastReport.Net\Demos\Reports\nwind.xml
5. Copy the contents of folder \FastReports\FastReport.Net\Demos\WCF to \Reports – it contains test reports
with built-in connections to the database, which are essential when used with library FastReport.Service.dll
6. Open the configuration file FastReport.Service.dll.config in any text editor
7. Change the path to the reports in section
www.fast-report.com 46 / 118
11. Open a web browser and go to address http://localhost:8732/FastReportService/
This shows the Service working normally. You can change the port number of the service in the configuration file:
www.fast-report.com 47 / 118
Let's connect to our service from the demo example \FastReport.Net\Demos\C#\WCFClient
1. Open WCFServiceClient.csproj in Visual Studio
2. Right-click in Solution Explorer on "Service References:ReportService" and select "Configure Service
Reference" in the popup
3. Review the service address, which should end with "/mex" (metadata exchange)
www.fast-report.com 48 / 118
www.fast-report.com 49 / 118
Creating Web Service using FastReport.Service.dll
There is an easy way to implement a web service using the library FastReport.Service.dll (WCF Service Library),
which is supplied with FastReport .Net.
Our example is based on creating a simple web application with web service functions, but you can modify your
existing project based on .NET Framework 4.0 or later.
Run Visual Studio and create a new ASP.NET Web Application project under .NET Framework 4.0.
www.fast-report.com 50 / 118
Add these lines to the file:
www.fast-report.com 51 / 118
<appSettings>
<!-- path to folder with reports -->
<add key="FastReport.ReportsPath" value="C:\Program files\FastReports\FastReport.Net\Demos\WCF" />
<!-- name of connection string for reports -->
<add key="FastReport.ConnectionStringName" value="FastReportDemo" />
<!-- Comma-separated list of available formats PDF,DOCX,XLSX,PPTX,RTF,ODS,ODT,MHT,CSV,DBF,XML,TXT,FPX.
You can delete any or change order in this list. -->
<add key="FastReport.Gear" value="PDF,DOCX,XLSX,PPTX,RTF,ODS,ODT,MHT,CSV,DBF,XML,TXT,FPX" />
</appSettings>
<connectionStrings>
<add name="FastReportDemo" connectionString="XsdFile=;XmlFile=C:\Program
Files\FastReports\FastReport.Net\Demos\Reports\nwind.xml"/>
</connectionStrings>
<system.serviceModel>
<services>
<service behaviorConfiguration="FastReportServiceBehavior" name="FastReport.Service.ReportService">
<endpoint address="" binding="wsHttpBinding" contract="FastReport.Service.IFastReportService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="FastReportServiceBehavior">
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding messageEncoding="Mtom"
closeTimeout="00:02:00" openTimeout="00:02:00"
receiveTimeout="00:10:00" sendTimeout="00:02:00"
maxReceivedMessageSize="67108864" maxBufferSize="65536"
transferMode="Streamed">
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
The key "FastReport.ReportsPath" should contain a path to the folder with the reports. You can set it to the demo
folder «\FastReport.Net\Demos\WCF», for example.
The key "FastReport.ConnectionStringName" should contain the connection string name. This line should be
registered in section .
Let's run our site and check the availability of a Web service by accessing the file ReportService.svc.
www.fast-report.com 52 / 118
When you deploy the project on the server, be sure to check that files FastReport.dll, FastReport.Bars.dll,
FastReport.Service.dll are in the folder \bin.
Examples of client programs can be found in the folders \FastReport.Net\Demos\C#\WCFClient and
\FastReport.Net\Demos\C#\WCFWebClient. Open each project in Visual Studio, right-click on ReportService and
select Configure Service Reference in the popup.
www.fast-report.com 53 / 118
Creating the WCF service hosted in windows service
Open Visual Studio and create a project WindowsService.
www.fast-report.com 54 / 118
Change the name of the service to your own choice:
www.fast-report.com 55 / 118
Edit the properties of the component serviceInstaller1 - set up a DisplayName.
In the component properties of serviceProcessInstaller1 set the type of account for the service as LocalSystem.
www.fast-report.com 56 / 118
Add references in the project to System.ServiceModel and FastReport.Service.dll :
www.fast-report.com 57 / 118
Copy the following text into the new app.config file:
<?xml version="1.0"?>
<configuration>
<appSettings>
<!-- path to folder with reports -->
<add key="FastReport.ReportsPath" value="C:\Program files\FastReports\FastReport.Net\Demos\WCF" />
<!-- name of connection string for reports -->
<add key="FastReport.ConnectionStringName" value="FastReportDemo" />
<!-- Comma-separated list of available formats PDF,DOCX,XLSX,PPTX,RTF,ODS,ODT,MHT,CSV,DBF,XML,TXT,FPX.
You can delete any or change order in this list. -->
<add key="FastReport.Gear" value="PDF,DOCX,XLSX,PPTX,RTF,ODS,ODT,MHT,CSV,DBF,XML,TXT,FPX" />
</appSettings>
<connectionStrings>
<add name="FastReportDemo" connectionString="XsdFile=;XmlFile=C:\Program
Files\FastReports\FastReport.Net\Demos\Reports\nwind.xml"/>
</connectionStrings>
<system.web>
<compilation debug="true" />
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider"
type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider,
System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri=""
/>
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider,
System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri=""
cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the
host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service behaviorConfiguration="FastReportServiceBehavior" name="FastReport.Service.ReportService">
<endpoint address="" binding="wsHttpBinding" contract="FastReport.Service.IFastReportService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/FastReportService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="FastReportServiceBehavior">
<serviceMetadata httpGetEnabled="True" />
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding messageEncoding="Mtom"
closeTimeout="00:02:00" openTimeout="00:02:00"
receiveTimeout="00:10:00" sendTimeout="00:02:00"
www.fast-report.com 58 / 118
maxReceivedMessageSize="67108864" maxBufferSize="65536"
transferMode="Streamed">
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
using System.ServiceModel;
public ReportService()
{
InitializeComponent();
}
You can install the service using the command line utility InstallUtil.exe, which comes with .NET Framework, for
instance:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe
"C:\MyProjects\WcfService1\WindowsService1\bin\Debug\WindowsService1.exe"
And you can start the service with the command:
net start ReportService
Open a web browser and check the address http://localhost:8732/FastReportService/, which was set in app.config
in baseAddress. You can change the folder and port to your own choice.
Commands to stop and to uninstall the service:
www.fast-report.com 59 / 118
net stop ReportService
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe /u
"C:\MyProjects\WcfService1\WindowsService1\bin\Debug\WindowsService1.exe"
This example is located in folder "\Demos\C#\WCFWindowsService".
www.fast-report.com 60 / 118
Working with Blazor
Presenting FastReport.Web package with components for embedding a web application into your Blazor Server.
Starting from version 2021.3, this library contains Razor components for the Blazor Server (server-side)
application, which means that all operations will be performed on the server side, which will then pass the finished
display to the client.
The minimum target framework at the moment is .Net Core 3.1 to ensure the highest possible compatibility with
the latest LTS (long-term support) version. Also, most users have this version and it is compatible with the latest
.NET 5 framework (within this package) and newer.
www.fast-report.com 61 / 118
Preflight Preparation
To use Blazor components in FastReport.Web , you need to add a reference in your project file (csproj)
PackageReference specifying the id of this package and the FastReport.Core package (versions may differ):
<ItemGroup>
<PackageReference Include="FastReport.Core" Version="2021.3.0-demo"/>
<PackageReference Include="FastReport.Web" Version="2021.3.0-demo"/>
</ItemGroup>
Then, to simplify naming, we recommend adding the following namespaces to your project's imports (
_Imports.razor file):
@using FastReport.Web
@using FastReport.Web.Blazor.Components
@using FastReport.Web.Blazor.Components.Internal
In fact, just adding FastReport.Web.Blazor.Components may be enough, however, for some cases, you may need
other namespaces as well.
Also, some components are likely to move within these namespaces during the beta version.
In the configurator of your web application, you need to call the UseFastReport method with an optional lambda
expression for setting FastReportOptions .
Also, for some built-in common styles and SVG images of icons in Toolbar and Tab to work, you need to use the
UseStaticFiles call (if you are not going to use Toolbar and Tabs, the UseStaticFiles call to use this package is
optional):
www.fast-report.com 62 / 118
Description of built-in components
The following is a description of the components included in FastReport.Web . We do not recommend using
components other than WebReportContainer , because they can be unstable outside of the standard component tree.
However, to fine-tune the rendering, you may need to use other components.
WebReportContainer
The main and most versatile Blazor component that performs WebReport rendering is <WebReportContainer/> . It is
located in the namespace FastReport.Web.Blazor.Components .
The only parameter it takes is an object of the WebReport class. This means that to use this component, you must
create an object of the WebReport class, assign it a Report , other necessary parameters, and pass this object to the
WebReportContainer parameters.
Example
@code {
public WebReport UserWebReport { get; set; }
This component can define a different Mode (Designer, Dialog, and normal Preview) and can prepare a report,
embed default styles and individual styles, display Toolbar, Outline and Tabs, work with interactive reports, etc.
WebReportPreview
It is similar to the previous component but does not take into account the Designer Mode. That is, it always tries to
prepare and render a report.
ReportContainer
It is similar to the previous component but does not include loading WebReport styles (common and individual for
Toolbar/Tabs/Outline).
It is engaged in the preparation of the report and subsequent display together with the Toolbar and Tabs (if
necessary).
www.fast-report.com 63 / 118
When working with any interactivity (clicks on the report / working with dialog forms), it is this component that is
updated.
ReportBody / ExportComponent
The ReportBody calls the Outline rendering (if necessary) and "nests" a component that is the rendering of the
report itself ( ExportComponent ), which the ReportContainer passes to it. Not recommended for use.
BlazorExport
The "lowest" level of a component is not a component at all, but BlazorExport itself - a tool for exporting a
prepared report to the RenderTreeBuilder build format. Located in FastReport.Web.Blazor.Export namespace.
To build this export, you must:
1. Prepare the report;
2. Make sure that this report does not use dialog forms (they are rendered using the DialogPageComponent and
are not covered in this tutorial);
3. Create your own component and explicitly define the construction method in it (call the override of the
BuildRenderTree method);
4. In this build method, create a BlazorExport instance, set the properties it needs, and call Export passing the
following parameters: a Report and a builder instance that is an argument to this overridden method.
blazor.Export(myReport, builder);
}
}
Online Designer
At the moment, Online Designer can work in the iframe element using javascript and it is fully compatible with the
Online Designer assembly for Core.
To use only the designer's capabilities, you can call the <IFrameDesigner/> component passing it the WebReport
parameter with the configured Report property and the optional DesignerLocale and DesignerPath :
However, we remind you that the WebReportContainer component understands which Mode it is currently working
with and it is not at all necessary to call IFrameDesigner in this form.
www.fast-report.com 64 / 118
Setting up common styles and SVG
Unlike FastReport.Web for Core, SVG images for Toolbar and Tabs, as well as some general display styles of Tabs,
Outline, etc. have been moved to staticWebAssets for possible customization in your web application (changing
colors, sizes, replacing images).
These resources are located in your local storage. At the time of development/assembly of your application, they
are located at: {UserName}/.nuget/packages/fastreport.web/{version}/staticwebassets
At the time of publishing your web application (dotnet publish), these resources are copied to the directory:
wwwroot/_content/FastReport.Web
www.fast-report.com 65 / 118
Demo project
You can find a project for demonstrating work with the FastReport.Web package on our GitHub. An example of
using the WebReportContainer is in the custom component under Pages/Index.razor and Pages/Index.razor.cs .
www.fast-report.com 66 / 118
Extending FastReport functionality
Create your own connection types
www.fast-report.com 67 / 118
Creating custom connection types
Data connections are used to add a data source to a report. This allows you to connect to data directly from the
report, rather than using data provided by the application.
To create your own connection you need to do the following:
create a connection class - a descendant of FastReport.Data.DataConnectionBase and implement some of its
methods;
create a connection editor - an heir of FastReport.Data.ConnectionEditors.ConnectionEditorBase and
implement the user interface and methods GetConnectionString , SetConnectionString ;
register the connection in FastReport.
These steps will be described below.
www.fast-report.com 68 / 118
DataConnectionBase class
To create your own connection, use the FastReport.Data.DataConnectionBase class. This class has the following set
of methods that you must override when creating your own connection:
Not all methods need to be overridden - some of them have a default implementation, which will be sufficient for
most cases. So, if your connection uses objects of type DbConnection and DbDataAdapter (and this is standard for
the vast majority of connections), you need to implement the following methods:
If your connection does not work with such objects, but, for example, is a bridge between the application server and
the report, you will need to implement the following methods:
www.fast-report.com 69 / 118
ConnectionString propery
Each connection type has its own set of parameters, such as database path, SQL dialect, username and password.
The ConnectionString property, which has a string type, is used to store the parameters.
This property is used as follows:
in the GetConnection method when creating an object of type DbConnection;
In the connection editor. In the latter case, individual parameters are selected from the connection string (e.g.,
the path to the database file). This uses a class of type DbConnectionStringBuilder , specific to each connection
type. For example, for MS SQL it is SqlConnectionStringBuilder .
www.fast-report.com 70 / 118
QuoteIdentifier method
An identifier (table or column name) is passed to this method. The method must return a quoted identifier.
Quotation marks are specific to each database. For example, MS Access uses square brackets:
You must override this method. Refer to the manual for this connection type to find out which characters are used
to refer to tables with long names.
www.fast-report.com 71 / 118
GetConnectionStringWithLoginInfo method
This method should take the existing connection string (from the ConnectionString property), include the
username and password information, and return the modified string. This method is used if the connection settings
specify "Ask for password when connecting".
For example, the implementation of this method for MsSqlDataConnection looks like this:
www.fast-report.com 72 / 118
GetConnection method
The method returns a new object of type DbConnection , specific to this connection. This object is used to connect to
the database when the table needs to be filled with data.
The connection parameters are taken from the ConnectionString property. For example, for MsSqlDataConnection ,
the method looks like this:
Most of the time you have to override this method. It is used in two other methods, FillTableSchema and
FillTableData . If your connection type does not use DbConnection and DbDataAdapter objects to get information
about the table and load data into it, you may not override this method. In that case, you must override the
FillTableSchema and FillTableData methods.
www.fast-report.com 73 / 118
GetAdapter method
The method returns a new object of type DbDataAdapter , specific to this connection. This object is used to fill the
table with data.
The following parameters are passed to the method:
Parameter Description
The method creates an adapter specific to MS SQL, fills the query parameters and returns the adapter. The
parameters should be described in more detail. The query text may contain parameters. In this case, a collection of
parameters in the parameters variable is passed to the method - these are the parameters defined in the
FastReport designer when the query was created. You must add the parameters to the
adapter.SelectCommand.Parameters list. Each parameter in the parameters collection has the following properties:
Property Description
DataType The data type of the parameter. This is an int type property; you must cast it to the type used for the
parameters in this connection.
Most of the time you have to override this method. It is used in two other methods, FillTableSchema and
FillTableData . If your connection type doesn't use the DbConnection and DbDataAdapter objects to get
information about the table and load data into it, you may not override this method. In that case, you must override
the FillTableSchema and FillTableData methods.
www.fast-report.com 74 / 118
GetEditor method
This method returns an instance of the editor for the given connection type. The implementation of the editor will
be discussed in "Connection Editor".
An example implementation of this method in MsSqlDataConnection :
www.fast-report.com 75 / 118
GetParameterType method
The value returned by this method is used in the query parameter editor to select the data type of the parameter:
www.fast-report.com 76 / 118
GetConnectionId method
The value returned by this method is used in the "Connection Wizard" to display short information about the
connection.
This value usually contains the name of the connection type and the name of the database. In MsSqlDataConnection
the implementation of the method looks like this:
Note that SqlConnectionStringBuilder is used to parse the connection string ( ConnectionString property).
You have to override this method.
www.fast-report.com 77 / 118
GetTableNames method
This method returns a list of tables and views in the database. As a rule, the GetSchema method of the
DbConnection object is used for this, which is returned by the GetConnection method.
This method has a standard implementation. In case the standard implementation is incompatible with your
connection type (i.e., it does not return a list of database entities), you will have to override this method. Consider
the MsSqlDataConnection implementation of this method as an example:
www.fast-report.com 78 / 118
TestConnection method
This method is called when you click the "Test" button in the connection settings.
The method has a default implementation that creates the connection and tries to open it:
If the test was successful, the method does nothing. Otherwise, an exception occurs when the connection is opened,
which is handled in the "Connection Wizard" and gives a window with an error text.
As a rule, you don't need to override this method. You may need it if your connection does not use a DbConnection
object to access the database (and therefore you do not return it in the GetConnection method).
www.fast-report.com 79 / 118
FillTableSchema method
The method fills in the table schema (i.e. field names and types).
The following parameters are passed to the method:
Parameter Description
The method has a default implementation that uses objects returned by the GetConnection and GetAdapter
methods:
In most cases, you do not need to override this method. You may need to do this if you don't use the DbConnection
and DbDataAdapter objects to access the data (and therefore don't implement the GetConnection and GetAdapter
methods).
www.fast-report.com 80 / 118
FillTableData method
The method fills the table with data.
The following parameters are passed to the method:
Parameter Description
The method has a default implementation that uses objects returned by the GetConnection and GetAdapter
methods:
In most cases, you do not need to override this method. You may need to do this if you don't use the DbConnection
and DbDataAdapter objects to access the data (and therefore don't implement the GetConnection and GetAdapter
methods).
www.fast-report.com 81 / 118
Connection Editor
To edit the connection, use a control of type UserControl, which is displayed in the connection selection window (in
the figure the control is highlighted with a red frame).
Each connection type has its own editor. All editors are inherited from the base class -
FastReport.Data.ConnectionEditors.ConnectionEditorBase :
www.fast-report.com 82 / 118
On the form of the editor, place the controls you need. Change the height of the editor to accommodate all the
elements. The width of the editor is fixed and cannot be changed.
The methods of the base class allow you to fill the controls with values from the connection and, conversely, to pass
values from the elements to the connection.
www.fast-report.com 83 / 118
GetConnectionString method
This method is called when you close the editor window with the OK button. It should return a connection string
that contains the values entered in the editor.
www.fast-report.com 84 / 118
SetConnectionString method
This method is called the first time the editor is displayed. It must parse the connection string into its component
parts and display their values in the editor. To parse a connection string, it is convenient to use a class of type
DbConnectionStringBuilder, which is available in every connection type. For example, for MS SQL it is
SqlConnectionStringBuilder .
www.fast-report.com 85 / 118
Registering a connection in FastReport
In order for your connection to be used in the FastReport designer, it must be registered. There are two ways to do
this.
Method 1: Your connection is part of your project (i.e. it is not in a separate .dll plugin). Registration is done using
the following code:
FastReport.Utils.RegisteredObjects.AddConnection(typeof(MyDataConnection));
This code must be executed once in the entire lifetime of the application, before you start the designer.
Method 2. Your connection is contained in a separate .dll plugin. In this case you can connect the plugin to
FastReport, and it will be loaded every time you work with the designer. To do this, you need to declare a public
class like FastReport.Utils.AssemblyInializerBase in the plugin and register your connection in its constructor:
When you load your plugin, FastReport will find classes like AssemblyInitializerBase and initialize them.
To attach a plugin to FastReport, bring up the designer and select the Settings... item in the View menu. In the
window that opens, select the "Plugins" tab and add your .dll plugin.
This can also be done by adding the module name to the FastReport configuration file. This file is created in the
user directory by default:
www.fast-report.com 86 / 118
Release Notes
Version 2022.3
Version 2022.2
Version 2022.1
Version 2021.4
www.fast-report.com 87 / 118
FastReport .NET 2022.3
New features
Skia support:
FastReport.Core now supports graphics and text rendering using the SkiaSharp library which is used instead of
System.Drawing.Common + libgdiplus on Linux systems (but also works on other operating systems).
For this, packages with the .Skia suffix are used:
FastReport.Core.Skia
FastReport.Web.Skia
This version has limited support for the .NET Framework and is mainly targeted at .NET Core/.NET projects. To use
it in your application, just change the package name FastReport.Core -> FastReport.Core.Skia, and add the
following packages to work on Linux (on Windows and macOS, the necessary packages are added automatically):
SkiaSharp.NativeAssets.Linux
HarfBuzzSharp.NativeAssets.Linux
Read more about Skia support in the next article.
Report validator
A "Validation" tab has been added to the report designer (on the right, next to the "Data" and "Report Tree" tabs).
Here you can check the report template and get a list of errors and warnings.
All this is displayed in a table with the object name (if there is one) and error description. If you select a row in the
table, the corresponding object will be highlighted in the designer.
Errors and warnings can be of the following types: unnamed objects, objects with the same name, overlapping
objects, objects with zero height or width, and objects that are partially or completely outside the parent object.
Objects without names and objects with the same name are critical errors. They can lead to various errors and even
www.fast-report.com 88 / 118
crash the application while preparing a report. Besides, without a validator, these errors are very hard to find.
Intersecting objects is not a serious error. In some cases, they can be useful and used purposefully (e.g., lines or
rectangles). Intersecting text objects, in most cases, can lead to incorrect exports. Especially in table exports, such as
Excel. The export will result in a lot of extra cells, etc. It is necessary to be careful with such objects.
Objects partially exceeding parent object boundaries (e.g. band or page) can also be useful in rare situations. But in
most cases, it causes errors in the preparation and export of the report.
Objects that are completely outside the parent one is a serious error. Finding such objects without a validator is
also very hard.
Intersecting objects and objects outside the parent can now be highlighted in color (which you can choose) if the
corresponding setting in designer options is enabled.
It is not necessary to use report validation. But it can be useful when your report doesn't work or look the way you
want it to.
Read more about report validator in the next article.
FRX Editor
Sometimes it is necessary to edit the contents of the FRX file using third-party text editors. Now you can do this
more conveniently, directly in the report designer. The FRX editor is added for this purpose. By default, it is
disabled. You can enable it in the designer options.
www.fast-report.com 89 / 118
In the report designer, the FRX tab will appear to the left of the Code tab.
The changes made here, will be immediately applied to the report and displayed on its pages.
Read more about the FRX editor in the following article.
StimulSoft report converter
Added the ability to convert report templates from StimulSoft to FastReport .NET templates.
StimulSoft reports may contain implementation objects that are not supported by the FastReport designer. These
objects will not be exported or will be replaced by others in such a way that the generated report is as similar as
possible to the one created in StimulSoft. It is important to note that the import of cross-bands is implemented by
moving their contents to the parent band.
www.fast-report.com 90 / 118
Read more about converting reports in the article at the following link.
Copying dialog pages
Added the ability to copy dialog pages. Both using the context menu of the dialog page and using the «Report ->
Copy Report Page» button.
Copying creates a copy of the dialog page with a unique name. All child objects will also have unique names.
However, the event handlers of the objects will be the same as those of the original page. If necessary, you must
create new handlers.
Also now dialog pages can be deleted not only with the «Report -> Delete Page» button, but also via the context
menu in the form editor and report tree.
Disabling last formatting settings
When creating an object in the designer, its settings will be applied to the next created object of the same type.
For example, if you create a text object, set its font size, borders, fill color, the next text object will be created with
the same settings.
This is useful when you need to create several objects with the same or similar settings.
In situations when you don't need this designer behavior you can disable it in options.
www.fast-report.com 91 / 118
This will create objects with default settings.
Export all tabs
When viewing interactive reports, you can open detailed reports in new tabs.
You can see three open tabs here. Previously, only the active tab was exported. Now you can export all tabs to one
file using the new "Export all tabs" option.
www.fast-report.com 92 / 118
Detailed description of referenced assemblies and installed plugins
Now when you hover your mouse over a dll in the plugins list (Options -> Plugins) and in the list of links to builds
(Report -> Options -> Script), detailed information with description, version, size, creation date, etc. is displayed.
Exports improvements
PDF export improvements:
Linux version:
support for complex languages (Arabic, Hebrew etc.) in Skia version;
All version:
support for Font Fallback (automatic font selection mechanism for displaying characters that are not
supported by the current font);
www.fast-report.com 93 / 118
A new UseFileStream option has been added for PDF export. It can only be used when exporting from code to file.
This option is useful when exporting reports with a large number of pages (several tens of thousands) in multiple
threads. It allows you to avoid memory shortage errors. In other cases, it does not make much sense to use it.
Example:
Export of locale in Word, PowerPoint, Rich Text, OpenOffice Write and OpenOffice Calc exports
You can now select the language of the document in these exports. By default the language selected in the designer
is used.
www.fast-report.com 94 / 118
added converting of PaperSize property when converting reports from StimulSoft;
added checking existence of referenced assembly when converting reports from StimulSoft;
added PrintOnParent property to Table and Matrix objects;
added loading of report parameters when converting reports from RDL;
added loading of subreports when converting reports from RDL;
added the feature to store JSON connection data using the StoreData property;
optimized speed in reports containing large amount of objects;
changed exception text when calculating and formatting expression if e.InnerException is null;
when loading RDL report, page width will be equal section width in case when there is no page width;
fixed length calculation encoding DataMatrix C40 and text;
handled System.ComponentModel.Win32Exception when printing with disabled Print Spooler;
fixed hide border of picture when printing with auto size;
fixed stack overflow error when prepare report with child band of page footer and then start new page option
enabled for it;
fixed a bug with not passing path of base report to current one in Unix OS;
fixed a bug with creating subreport and page with the same name when converting reports from StimulSoft;
fixed a bug with invalid names when converting reports from StimulSoft;
fixed a bug with TotalPages in Page.VisibleExpression that causes an exception when double pass is disabled;
fixed a bug when band can grow out of page;
fixed a bug when objects can grow out of band or ContainerObject;
fixed "back indent" feature in RTF translator;
fixed RichText line spacing when RTF translated to report objects;
fixed an error with ConnectionString property in JsonDataSourceConnectionStringBuilder class when value
was without a request headers;
[Designer]
added the report validator that helps to find invalid objects (duplicate names, negative sizes, etc.);
added editor for RichObject.Text property;
added FRX editor in report designer;
added detailed description of referenced assemblies and installed plugins;
added the ability to copy dialog pages;
added the ability to delete dialog pages using the context menu;
added ability to disable using of last formatting options when creating objects;
added integration with FastReport.Id;
added call to online-documentation in the report designer;
added wizard for visualization of control identification signs;
add tooltip about right and bottom indents for guides and objects in designer;
added ability to select color of backlight intersecting objects in designer;
added possibility to connect bases of Access 2007;
changed the look of ElasticSearch connection editor form;
changed the text fields in CISWizardForm with units to text fields that only support numbers;
fixed a bug leading to System.NullRefereceException when creating calculated column for subtable JSON;
fixed a bug leading to System.FormatException when drawing labels of maps;
fixed a bug leading to the System.NullReferenceException when clicking the "Paste" button in the context
menu of dialog pages;
fixed a bug with scaling zoom controls of designer in HiDPI mode when run from old demo application;
fixed opening form of save changes after save all report;
fixed unscalable items in welcome window;
fixed backlighting intersected charts;
fixed exception on rename JSON table;
-
www.fast report.com 95 / 118
fixed UpdateStatusBar in DialogWorkspace;
fixed a bug with localization of "Account..." button in menu "File";
fixed canceling selection of object if its properties are changed;
fixed a bug when switching to the "Code" page did not occur after adding an event handler;
[Preview]
implemented export of all open tabs;
fixed a bug leading to System.NullReferenceExteption when preparing report with RichObject on system
without printers;
fixed a bug in the MSChart object in HiDPI mode;
[Exports]
added export of locale in Word, PowerPoint, Rich Text, OpenOffice Write and OpenOffice Calc exports;
added encryption of the password of the digital signature certificate in PDF-export when it is saved;
added option "Show gridlines" when exporting to Excel 2007;
added data types export to DBF;
added a new property to the SVG export PrefixStyle, which allows you to set a prefix for all styles inside the
SVG export;
added option "Use locale formatting of data" when exporting to Excel 2007;
added PDFExport.UseFileStream property, which allows to export huge reports on systems with low amount
of RAM without System.OutOfMemoryException;
set UTF-8 as default encoding in DBF export;
fixed incorrect scaling pictures in layered HTML-export when enabled high quality SVG and zoom more than
1;
fixed a bug leading to System.IndexOutOfRangeException when exporting font without kerning to PDF;
fixed a bug with scaling picture in layered HTML-export;
fixed a bug leading to System.NullReferenceException when exporting report with empty page to Word 2007;
fixed memory leak in PDF export with some CJK fonts;
fixed a bug when SVG picture was not rotated to needed angle in HTML/Blazor export;
fixed repeated rendering of table cell in SVG export;
fixed incorrect pageStyle when printing from browser for table HTML export;
fixed exception when export object with negative size in HTML export;
fixed export to pdf if Compressed = false;
fixed incorrect record of border-collapse property in table HTML-export;
fixed a bug in Excel-export, when the fill in the output file did not change the first time;
fixed export of watermark to PostScript;
fixed error of font scale when export to PDF;
fixed a bug where a text object with HtmlTags exported to RTF was not modified by the
, , tags;
[WebReport]
onlineDesigner properties are moved to webReport.Designer with backwards compatibility;
www.fast-report.com 96 / 118
fixed a bug when event "CheckedChanged" handled by RadioButton was not performed;
fixed incorrect scaling of Dialog components in Blazor;
fixed a bug with incorrect font size in Excel export;
fixed a bug in Blazor when font of text object with property TextRenderType = HtmlParagraph was always
default;
[.NET Core]
fixed incorrect search for public-methods in report script;
fixed problem of creating a fontlist file on Azure;
[CoreWin]
fixed behavior of WinForms components in Toolbox for Visual Studio (Design-Time);
fixed incorrect launch of the browser when clicking on links in CoreWin;
for FastReport.CoreWin, reports with a script that use the WinForms API have been fixed;
[Demos]
added the ability to change the localization of a new demo application without restarting it;
added demo on React with FastReport.Core;
fixed position of one chart in Chart.frx;
[Plugins]
implemented connection to Cassandra;
updated RPTImportPlugin;
[Extras]
added FastReprot.Web (only for .NET Framework) and FastReport.VSDesign libraries for FastReport.Net*
packages;
added an option to import reports using streams;
[Service]
fixed incorrect version of FastReport.Compat in FastReport.Net packages.
www.fast-report.com 97 / 118
FastReport .NET 2022.2
New features
Fast Reports NuGet-server
We recently launched our own NuGet-server - a repository of licensed Fast Reports products for users. Now you
can conveniently download the latest versions of our components on any operating system.
More details in article.
www.fast-report.com 99 / 118
Ability to use XLSX files as data sources
You can now retrieve data from Excel 2007 files as from a database and use it in a report.
Read more in article.
Exports Improvements
"Pinned cells" option when exporting to Excel 2007
This feature, allows you to define an area of the sheet that will always be visible when you scroll. You can lock: the
first row, the first column, a certain number of rows and columns.
The settings look like this:
Here you can see that the table has a field named FistName, but it's not specified correctly in the expression.
Exports improvements
Implemented export of watermark to Word and RTF.
Added SVG image scaling in export matrix.
This improves the quality of exported images when exporting to Word and Excel. However, this increases the size of
the output file. To use this feature, you must enable the "Print optimized" option when exporting.
Export groups to single sheets in Excel 2007 has been implemented.
Excel 2007 has added the ability to export a property that determines the size and location of the image
when exporting.
Now you can define how the image will behave in a cell when its position and size are changed. In doing so, the
image can:
move and resize together with the cell
move together with the cell, but not change its size
don't move or resize
Implemented the ability to hide or show grid lines when exporting to Excel 97.
Added "Don't rotate landscape pages when printing" option in HTML export.
Previously, we were forcibly rotating landscape-oriented pages when printing. The reason was that browsers
.NET 6 support
Added .NET 6 support for FastReport.Core and FastReport.CoreWin.
The export settings window can be customized using the webReport.Toolbar.Exports.Color and
webReport.Toolbar.Exports.FontSettings properties.
New features
Added new Visual Studio-styled icons. You may switch between icon packs in the "View/Options/User
Interface" window (or, "File/Options/User Interface" if you use ribbon UI):
It makes the report look cleaner especially when it contains a lot of small objects. You still can see a full text of
object in the status bar.
Added ability to set up each cell in the Matrix object's corner area. To do this use the cell's context menu and
its commands "Split cell", "Merge cells":
www.fast-report.com 111 / 118
Added ability to connect to ElasticSearch. Connection available in data wizard and from code.
Added barcode Japanese Post 4 - State Code.
Added the collapse all/expand all buttons and, a search field for the report tree and data tree in the designer.
When clicking on + tree will expand. On - tree will collapse.
These changes should simplify working with reports containing many objects and/or data sources.
The RicthText to report objects converter has been significantly improved and optimized.
The number of available exports in WebReport Core/Blazor Server has increased significantly.
Added FastReport Business Graphics integration objects (\Extras\Objects\FastReportBGObjects).
<ItemGroup>
<TrimmerRootAssembly Include="System.Security" />
</ItemGroup>
Localizations
In the logic of the localization change small changes were made.
1. Added package FastReport.Localization. This package contains localization files for FastReport.NET,
FastReport.Core, FastReport.CoreWin, FastReport.Mono, FastReport.OpenSource products and creates the
Localization directory in the output directory of the user project when adding this package.
2. Added new API for changing the localization using the CultureInfo type -
FastReport.Utils.Res.LoadLocale(CultureInfo culture).
When this method is called, FastReport searches for the appropriate localization for the selected culture.
Loaded locales are cached. For this method to work correctly, you must install the FastReport.Localization
package from step 1 in your project or set the path to the folder with the localization files in the
FastReport.Utils.Res.LocaleFolder property.