New to Telerik ReportingStart a free 30-day trial

Create a Report Programmatically

To create a Telerik report in code, you need to instantiate a Telerik.Reporting.Report object and set its properties. For example, this code will create a report and set up its data source:

C#
Telerik.Reporting.Report report = new Telerik.Reporting.Report();
string selectCommand = @"SELECT * FROM Sales.Store";
string connectionString = "Data Source=(local)\\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True";
Telerik.Reporting.SqlDataSource sqlDataSource = new Telerik.Reporting.SqlDataSource(connectionString, selectCommand);
report.DataSource = sqlDataSource;

Next Steps

The code sample above demonstrates how to create an empty report. To create a functional report, you can add sections and items in code.

When you create reports programmatically, you must use a Custom Report Source Resolver to display these reports in a Report Viewer that utilizes Telerik Reporting REST Service to render its reports.

You can also programmatically export the report that you created.

See Also

In this article
Next StepsSee Also
Not finding the help you need?
Contact Support