Report parameters
In this article, we will look at the process of passing parameters to a report, which represent a dictionary of parameters provided when generating the report. More information on this topic can be found in the FastReport .NET manual in the section Report parameters.
Getting Started
You will need the following tools and features:
Knowledge of using API key in FastReport Cloud.
This article will skip additional information on authentication and authorization.
A C# code editor or a text editor such as Visual Studio Code.
Report template with the specified report parameters.
It can be created using the free program FastReport Community Designer.
Active FastReport Cloud subscription.
Access to the Internet.
Note! This guide assumes that you already know how to develop your application in the C# programming language.
Note! The paragraphs above describe the recommended tools.
Passing a value to a report parameter
Parameters can be passed in the following cases:
- Prepare template;
- Export template;
- Working with tasks.
Let's look at the passing of parameters using an example of preparing a template. Detailed instructions on how to prepare a report can be found in the section Building a report.
public async Task PassingReportParameters(HttpClient httpClient,
string folderId,
string templateId,
string fileName)
{
ITemplatesClient templatesClient = new TemplatesClient(httpClient);
PrepareTemplateVM task = new PrepareTemplateVM()
{
Name = Path.ChangeExtension(fileName, ".fpx"),
FolderId = folderId,
ReportParameters = new Dictionary<string, string>
{
{ "Parameter1", "Value1" },
{ "Parameter2", "Value2" }
}
};
// Add a new parameter to the dictionary
task.ReportParameters.Add("Parameter3", "Value3");
ReportVM result = await templatesClient.PrepareAsync(templateId, task);}