This is a migrated thread and some comments may be shown as answers.

How to create Report programmatically?

1 Answer 308 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Goliath Vader
Top achievements
Rank 1
Goliath Vader asked on 06 Aug 2013, 07:08 AM
There is documentation on how to program a Graph (http://www.telerik.com/help/reporting/graphhowtocreateprogrammaticallygraph.html), but I can't find any to programmatically create a Telerik Report.- How do you do this?

I have tried this, but am not sure if I am on the right track?
Following the Graph's tutorial, what Telerik.Reporting.Report() properties must I set, other than 'Name'?


    public partial class Report1 : Telerik.Reporting.Report
    {
        public Report1()
        {
            //InitializeComponent();  //Not used, as not using Designer...right??
 
            //Set up the datasource:
            Telerik.Reporting.SqlDataSource sqlDataSource = new Telerik.Reporting.SqlDataSource();
            sqlDataSource.ProviderName = "System.Data.SqlClient";
            sqlDataSource.ConnectionString = "Data Source=...";
            sqlDataSource.SelectCommand = "SELECT...";
 
            //Instantiate report:
            var report = new Telerik.Reporting.Report();
            report.Name = "theReport"; //What other properties must I set??
             
            //Set the data item's DataSource property to the SQL datasource:
            report.DataSource = sqlDataSource;
 
            //Some parameters:
            sqlDataSource.Parameters.Add("@Fields.Name", System.Data.DbType.String, "Blade");
 
            //Export to PDF:
            exportToPDF(report);
             
           }
}

1 Answer, 1 is accepted

Sort by
0
Squall
Top achievements
Rank 1
answered on 06 Aug 2013, 01:16 PM
Just create the required report with the VS report designer and then check the serialized code in the InitializeComponent(). All of the code that is required is serialized in this method and you can use it as a base for yours.
Tags
General Discussions
Asked by
Goliath Vader
Top achievements
Rank 1
Answers by
Squall
Top achievements
Rank 1
Share this question
or