When developing reports in FastReport .NET, users often need an efficient way to organize their data. The Data Dictionary is a tool that transforms report creation from a chaotic process into a structured and efficient workflow. It is important to understand that the Data Dictionary does not store the actual data (such as table rows). Instead, it stores only the metadata—the description of the data structure.
In this article, we'll take a closer look at what the Data Dictionary is, how to work with it, and the capabilities it provides.
Â
All Data Dictionary management operations are available from the Actions drop-down menu. The New Data Dictionary command completely clears the current structure and creates a new, empty dictionary.
To work with dictionary files, use the Open Dictionary... and Save Dictionary... commands. The first option loads a previously saved dictionary file, while the second saves the current configuration so it can be reused in other projects.
The Merge Dictionaries... command is used to integrate elements from an external dictionary file into the current report. Keep in mind that if object names in the external dictionary match those already present in the current dictionary, the existing objects will be completely replaced. Therefore, before starting the merge process, make sure that object names are unique to avoid accidentally overwriting or losing existing definitions.
Â
Â
Let's create the first report with the following data:
The Data Dictionary contains the following items:
Now save the Data Dictionary from the first report. From the Actions menu, select Save Dictionary... and save the configuration as Dictionary1.frd.
Next, create a new report with a different set of data:
The new report contains:
Now merge the Data Dictionaries from these two reports. From the Actions menu, select Merge Dictionaries... and choose the previously saved Dictionary1.frd file.
The result will look as shown in the image below:
After the merge, the report contains all elements from both dictionaries:
Â
Â
Programmatic management of the Data Dictionary is performed through the Dictionary property of the Report object. The Load and Save methods work directly with .frd file paths, making it easy to import and export Data Dictionary configurations:
Report report = new Report(); report.Load(@"C:\Reports\MainReport.frx"); // Loading dictionary from file report.Dictionary.Load(@"C:\Reports\Dictionary.frd"); // Saving dictionary to file report.Dictionary.Save(@"C:\Reports\ExportedDictionary.frd"); report.Design();
To merge Data Dictionaries, the Merge method requires the external dictionary to be loaded into a separate Dictionary object first:
Report report = new Report(); report.Load(@"C:\Reports\MainReport.frx"); // Create a temporary Data Dictionary and load the data into it var extraDict = new FastReport.Data.Dictionary(); extraDict.Load(@"C:\Reports\AdditionalData.frd"); // Merge it with the report's main Data Dictionary report.Dictionary.Merge(extraDict); report.Design();
Â
Â
In this article, we've explored what the Data Dictionary is in FastReport .NET and how it simplifies working with report data. We covered how to manage the Data Dictionary both through the graphical user interface and programmatically.
You can now automate report creation, manage reusable report templates, and build flexible reporting solutions that are easy to scale and maintain across your team.
Â