Exporting a list of all parameters, data sources, and fields used in a report

1 Answer 382 Views
.NET Core
Ryan
Top achievements
Rank 1
Iron
Iron
Ryan asked on 17 Mar 2022, 01:01 AM

I would like to export all the database objects used within a report (.trdp file), and the number of times each reference is used. The rationale is we need to be able to easily identify all the database objects (e.g., tables and columns) used in a report whenever schema change discussions arise. This would include columns used in text elements, tables, charts, expressions, and so on.

Example:

REPORTDATASOURCETABLENAMEFIELDNUM_REFERENCES
FacilitiesReport.trdpfacilitiesfacilityid1
FacilitiesReport.trdpfacilitiesfacilityname2
FacilitiesReport.trdpfacilitiesfacilityzip_code1
FacilitiesReport.trdpfacilitiescityzip1
FacilitiesReport.trdpfacilitiescityname3
FacilitiesReport.trdpfacilitiescitystate1

I doubt this exists out of the box so I figure I need to script something. I am considering creating an instance of a report and looping through all the objects and collecting all datasource and field references in a dictionary and then exporting the completed dictionary to a csv.

I could also unzip the trdp file and parse the xml, but if the schema changes from version to version I could wind up with brittle or broken code.

Has anyone here down something similar? Recommendations?

 

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 21 Mar 2022, 09:38 AM

Hello Ryan,

Indeed, we do not offer such functionality out of the box.

The closest thing that we offer is the CSV rendering extension. The Comma-Separated Value (CSV) rendering output reports as a flattened representation of the report data in a plain-text format. From what I have understood, your goal is pretty much the same with the difference that the exported CSV will not look exactly the same as in the example.

Other than this, you would have a hard time achieving this task because the DataSource components in Telerik Reporting don't contain any actual data. They hold only meta-information on how to fetch the data during the report processing stage. For example, the connection string to connect to the database and the query to be executed. In run-time, our code passes this meta-data to the specified ADO.NET provider and waits for the actual data to be returned.

With that being said, there are possibly a couple of things that you can try:

  • You could get a list of the data source of the report. For example:
var sqlDataSources = report.GetDataSources().OfType<SqlDataSource>(); //get all sqldatasources

This would get you all data sources of type SqlDataSource. Each of them should have a SelectCommand which will be the query string that will be executed at runtime so, with this information, you can know what data is being extracted in the report.

  • You could use an ObjectDataSource component where you may write custom code for getting the data. When you have retrieved the data, you may do whatever you need with it such as exporting it to CSV.

I hope that the provided information will be of use to you.

Regards,
Dimitar
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
Tags
.NET Core
Asked by
Ryan
Top achievements
Rank 1
Iron
Iron
Answers by
Dimitar
Telerik team
Share this question
or