Example 1. Creating a report manually
In this example, we will create a report manually. For this, we will do the following:
- press the
button on the toolbar, and in the "Add New Item" window, choose "Blank report";
- in the "Data" menu, choose the "Choose Report Data..." item and check the "Products" data source:
The second option is how you can add your data from an XML file:
- in the "Data" menu, select "Add Data Source...". The Data Wizard form opens;
- click on the "New Connection..." button;
- select the connection type: XML database. Click on the icon of the data file or URL:
- in the Open File dialog box, navigate to the location of the file, for example C:\Program Files (x86)\Fast Reports\2024.2.12\FastReport .NET Trial\Demos\Reports, then select nwind.xml;
- to check the connection to the database, click on the "Test connection" button. If the connection test is completed successfully, click OK to close the Connection window;
- in the Data Wizard, click the Next button;
- expand the root node of the "Tables", then select the "Products" table and click Finish:
- switch to the "Data" service window (if it is not on the screen, it can be shown by choosing the "Data|Show Data Window" menu item). Expand the "Data Sources" item, then the "Products" item:
- drag the
ProductName
data column onto the "Data" band. FastReport creates a "Text" object, which is connected to this column and a header for it; - we will create the
UnitPrice
data column by using another method. For this, press the "Text" button on the "Objects" toolbar:
- leave the mouse and drag its pointer onto the "Data" band - you will see that FastReport offers to insert an object. Choose the needed position and click the mouse to insert the object;
- place the mouse pointer on the object and click the small button in the right corner of the object. You will see a list of data columns. Choose the
UnitPrice
item from the list:
- create the "Text" object - header for the
UnitPrice
column. Place in on the "Page Header" band. Double click the object and write the text "Unit Price"; - create the "Text" object - report title. Place it on the "Report Title" band and write the text "PRODUCTS";
- set "Bold" as font style for all objects that are placed on the "Page Header" and "Report Title" bands. For this, select objects by pressing Shift, and press the
button on the "Text" toolbar. After this, the report will be looking like this:
Ways to run the report:
- using the button
on the control panel;
- using the keyboard shortcut Ctrl+P.
The report will be built and shown in the preview window: