I am trying to export the reporting dataset to CSV. The built-in export to CSV function does not fit my needs as my use case is for a CSV export of all data used to plot the line-graph that the user is currently looking at. In order to do this, I have created a function on the report which outputs the datasources and I then extract the SQL query, add the user selected parameters and then re-execute the statement against the DB.
I have several questions about this -
- This feels like a huge overhead given that the dataset has already been pulled from the database but I cannot find any way to access the datatable used by the report. Can I access the reports datatable?
- I am using the HTML5 report viewer and cannot find any way to access the InstanceReportSource, this means I can't access the parameters sent to the report and I need to get the parameters from the ReportViewer instead. This is problematic as the parameters aren't loaded until after the user clicks Preview; our reports automatically load and 50% of the time this will be the CSV data that the user wants. As a work around I have added a function that will return the default values used upon the reports first run but again, thIs feels like a huge overhead and gives us maintainability issues etc. Is there a way to access the InstanceReportSource so I can get the parameters used by the report?
- I am open to suggestions that will make this easier/more maintainable, is there a better way to solve this problem?