Programmatically create report

I have coded a custom statement generation program and I am using the HTML report template to generate a cover note. I would like to allow the user to create their own HTML template but do not want to allow them to use the Report Manager screens (too many fields, controls). By selecting the Report entity and the default report template, I can query out the HTML content in the template, edit it and then save it back into the Report Template entity. This works.

But when try to use my screen to create a new Report entity and template, I create the Report Entity, ReportTemplate entity and BandDefinitions and save it. It shows up in Report Manager but this report cannot is be used. When I edit the new report in Report manager, the Root band is missing.

Is there an API, a service or a correct way to create a new Report in my program ?

As far as I know, there is no programmatic API to create Report entities.
You can compare your data structure with the structure which is formed in the ReportEditor, just before saving the report to database.
E.g. put a breakpoint here:
and look in the debugger how the report stored in the getItem() looks like.

Maybe you are missing this code from the

        String xml = reportService.convertToString(getItem());

Thanks for the tip on setXml. Yes, I found that I need to create the report entities (Report, BandDefinition, ReportTemplate) and configure them.

Then use the reportService.convertToString to get the XML version and then set it back to the report.


Finally, call this to save:


MyReport report = new MyReport();
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;